Skip to content

Commit 23bd3ea

Browse files
dfaure-kdabogoffart
authored andcommitted
Print property name when detecting a recursion (requires slint_debug_property)
1 parent fa78179 commit 23bd3ea

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

internal/core/properties.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,17 @@ impl PropertyHandle {
525525
/// Access the value.
526526
/// Panics if the function try to recursively access the value
527527
fn access<R>(&self, f: impl FnOnce(Option<Pin<&mut BindingHolder>>) -> R) -> R {
528+
#[cfg(slint_debug_property)]
529+
if self.lock_flag() {
530+
unsafe {
531+
let handle = self.handle.get();
532+
if handle & 0b10 == 0b10 {
533+
let binding = &mut *((handle & !0b11) as *mut BindingHolder);
534+
let debug_name = &binding.debug_name;
535+
panic!("Recursion detected with property {debug_name}");
536+
}
537+
}
538+
}
528539
assert!(!self.lock_flag(), "Recursion detected");
529540
unsafe {
530541
self.set_lock_flag(true);

0 commit comments

Comments
 (0)