Mark aliases as used (and potentially overwritten) by derived component

Fix #1009
This commit is contained in:
Olivier Goffart 2022-03-04 11:48:01 +01:00
parent 59f06ed1b2
commit a0c914c43e
2 changed files with 31 additions and 0 deletions

View file

@ -467,6 +467,12 @@ fn propagate_is_set_on_aliases(component: &Rc<Component>, reverse_aliases: &mut
let is_binding_constant =
binding.is_constant() && binding.two_way_bindings.iter().all(|n| n.is_constant());
if is_binding_constant && !NamedReference::new(e, name).is_externally_modified() {
for alias in &binding.two_way_bindings {
crate::namedreference::mark_property_set_derived_in_base(
alias.element(),
alias.name(),
);
}
return;
}

View file

@ -0,0 +1,25 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
Button := Text { }
PanelButton := HorizontalLayout {
property<string> button-text <=> button.text;
button := Button { }
}
TestCase := Window {
property <bool> test: pb.preferred-height == control.preferred-height;
pb := PanelButton { button-text: "button1"; }
control := Text { text: "button1"; }
}
/*
```rust
let ui = TestCase::new();
assert!(ui.get_test());
```
*/