live-preview: Recursively set debug-handler

This commit is contained in:
Tobias Hunger 2025-06-10 11:02:29 +00:00 committed by Tobias Hunger
parent bd3c001c5d
commit d21e6680a3
2 changed files with 15 additions and 2 deletions

View file

@ -965,9 +965,10 @@ impl ComponentDefinition {
handler: impl Fn(&Option<i_slint_compiler::diagnostics::SourceLocation>, &str) + 'static,
_: i_slint_core::InternalToken,
) {
generativity::make_guard!(guard);
let handler = Rc::new(handler);
*self.inner.unerase(guard).debug_handler.borrow_mut() = handler;
generativity::make_guard!(guard);
self.inner.unerase(guard).recursively_set_debug_handler(handler);
}
/// Creates a new instance of the component and returns a shared handle to it.
pub fn create(&self) -> Result<ComponentInstance, PlatformError> {

View file

@ -703,6 +703,18 @@ impl ItemTreeDescription<'_> {
let g = extra_data.globals.get().unwrap().get(global_name).clone();
g.ok_or(())
}
pub fn recursively_set_debug_handler(
&self,
handler: Rc<dyn Fn(&Option<i_slint_compiler::diagnostics::SourceLocation>, &str)>,
) {
*self.debug_handler.borrow_mut() = handler.clone();
for r in &self.repeater {
generativity::make_guard!(guard);
r.unerase(guard).item_tree_to_repeat.recursively_set_debug_handler(handler.clone());
}
}
}
#[cfg_attr(not(feature = "ffi"), i_slint_core_macros::remove_extern)]