mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-02 12:58:23 +00:00
Fix assertion when computing the analysis and trying to get into a repeater
Could be reproduced by building cargo-ui
This commit is contained in:
parent
5248468c74
commit
9b7997730a
2 changed files with 43 additions and 4 deletions
|
|
@ -68,15 +68,34 @@ impl PropertyPath {
|
|||
&element.borrow().enclosing_component.upgrade().unwrap().root_element,
|
||||
) {
|
||||
if let Some(last) = elements.pop() {
|
||||
debug_assert!(Rc::ptr_eq(
|
||||
last.borrow().base_type.as_component(),
|
||||
&element.borrow().enclosing_component.upgrade().unwrap(),
|
||||
));
|
||||
#[cfg(debug_assertions)]
|
||||
fn check_that_element_is_in_the_component(
|
||||
e: &ElementRc,
|
||||
c: &Rc<Component>,
|
||||
) -> bool {
|
||||
let enclosing = e.borrow().enclosing_component.upgrade().unwrap();
|
||||
Rc::ptr_eq(c, &enclosing)
|
||||
|| enclosing
|
||||
.parent_element
|
||||
.upgrade()
|
||||
.map_or(false, |e| check_that_element_is_in_the_component(&e, c))
|
||||
}
|
||||
#[cfg(debug_assertions)]
|
||||
debug_assert!(
|
||||
check_that_element_is_in_the_component(
|
||||
&element,
|
||||
last.borrow().base_type.as_component()
|
||||
),
|
||||
"The element is not in the component pointed at by the path ({:?} / {:?})",
|
||||
self,
|
||||
nr
|
||||
);
|
||||
element = last.0;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
debug_assert!(elements.last().map_or(true, |x| *x != ByAddress(nr.element())));
|
||||
Self { elements, prop: NamedReference::new(&element, nr.name()) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
20
tests/cases/crashes/layout_if_in_component.60
Normal file
20
tests/cases/crashes/layout_if_in_component.60
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright © SixtyFPS GmbH <info@sixtyfps.io>
|
||||
// SPDX-License-Identifier: (GPL-3.0-only OR LicenseRef-SixtyFPS-commercial)
|
||||
|
||||
|
||||
export Btn := Rectangle {
|
||||
min-height: max(32px, l.min-height);
|
||||
l := HorizontalLayout {
|
||||
if (false): button_in_image := Image {
|
||||
width: 24px;
|
||||
}
|
||||
text := Text { }
|
||||
}
|
||||
}
|
||||
|
||||
export TestCase := Window {
|
||||
x := HorizontalLayout {
|
||||
btn := Btn {}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue