mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-31 07:37:24 +00:00
Route debug() calls in Slint consistently through Platform's debug_log() (#5718)
This commit is contained in:
parent
d8e7226cd5
commit
8a7db55bb6
4 changed files with 12 additions and 7 deletions
|
@ -124,6 +124,11 @@ upgrade_item_weak(const cbindgen_private::ItemWeak &item_weak)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void debug(const SharedString &str)
|
||||||
|
{
|
||||||
|
cbindgen_private::slint_debug(&str);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace private_api
|
} // namespace private_api
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
@ -152,6 +152,11 @@ pub extern "C" fn slint_string_to_float(string: &SharedString, value: &mut f32)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn slint_debug(string: &SharedString) {
|
||||||
|
i_slint_core::debug_log!("{string}");
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
mod allocator {
|
mod allocator {
|
||||||
use core::alloc::Layout;
|
use core::alloc::Layout;
|
||||||
|
|
|
@ -127,12 +127,7 @@ pub fn debug(s: SharedString) {
|
||||||
#[cfg(feature = "log")]
|
#[cfg(feature = "log")]
|
||||||
log::debug!("{s}");
|
log::debug!("{s}");
|
||||||
#[cfg(not(feature = "log"))]
|
#[cfg(not(feature = "log"))]
|
||||||
{
|
i_slint_core::debug_log!("{s}");
|
||||||
#[cfg(all(feature = "std", not(target_arch = "wasm32")))]
|
|
||||||
println!("{s}");
|
|
||||||
#[cfg(any(not(feature = "std"), target_arch = "wasm32"))]
|
|
||||||
i_slint_core::debug_log!("{s}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ensure_backend() -> Result<(), crate::PlatformError> {
|
pub fn ensure_backend() -> Result<(), crate::PlatformError> {
|
||||||
|
|
|
@ -3128,7 +3128,7 @@ fn compile_builtin_function_call(
|
||||||
BuiltinFunction::AnimationTick => "slint::cbindgen_private::slint_animation_tick()".into(),
|
BuiltinFunction::AnimationTick => "slint::cbindgen_private::slint_animation_tick()".into(),
|
||||||
BuiltinFunction::Debug => {
|
BuiltinFunction::Debug => {
|
||||||
ctx.generator_state.conditional_includes.iostream.set(true);
|
ctx.generator_state.conditional_includes.iostream.set(true);
|
||||||
format!("std::cout << {} << std::endl;", a.join("<<"))
|
format!("slint::private_api::debug({});", a.join(","))
|
||||||
}
|
}
|
||||||
BuiltinFunction::Mod => {
|
BuiltinFunction::Mod => {
|
||||||
ctx.generator_state.conditional_includes.cmath.set(true);
|
ctx.generator_state.conditional_includes.cmath.set(true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue