mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-03 05:12:55 +00:00
Fix property wrongly considered as const if it is modified through an alias
Fixes #4241
This commit is contained in:
parent
a4f2b45d9a
commit
96324a8300
2 changed files with 69 additions and 6 deletions
|
|
@ -83,13 +83,14 @@ impl NamedReference {
|
|||
return false;
|
||||
}
|
||||
|
||||
if check_binding {
|
||||
if let Some(b) = e.bindings.get(self.name()) {
|
||||
if !b.borrow().analysis.as_ref().map_or(false, |a| a.is_const) {
|
||||
return false;
|
||||
}
|
||||
check_binding = false;
|
||||
if let Some(b) = e.bindings.get(self.name()) {
|
||||
if check_binding && !b.borrow().analysis.as_ref().map_or(false, |a| a.is_const) {
|
||||
return false;
|
||||
}
|
||||
if !b.borrow().two_way_bindings.iter().all(|n| n.is_constant()) {
|
||||
return false;
|
||||
}
|
||||
check_binding = false;
|
||||
}
|
||||
if let Some(decl) = e.property_declarations.get(self.name()) {
|
||||
if let Some(alias) = &decl.is_alias {
|
||||
|
|
|
|||
62
tests/cases/issues/issue_4241_alias-const.slint
Normal file
62
tests/cases/issues/issue_4241_alias-const.slint
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
|
||||
|
||||
|
||||
export component SpinBoxBase {
|
||||
in-out property <int> value;
|
||||
}
|
||||
|
||||
|
||||
export component SpinBox {
|
||||
in-out property <int> value <=> i-base.value;
|
||||
i-base := SpinBoxBase {
|
||||
width: 100%;
|
||||
}
|
||||
TouchArea {
|
||||
clicked => {
|
||||
i-base.value += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export component TestCase {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
trials:=SpinBox {
|
||||
value: 5;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
t:=Text {
|
||||
text: "Value: "+ trials.value;
|
||||
}
|
||||
out property <string> val: t.text;
|
||||
}
|
||||
|
||||
/*
|
||||
```cpp
|
||||
auto handle = TestCase::create();
|
||||
const TestCase &instance = *handle;
|
||||
|
||||
assert_eq(instance.get_val(), "Value: 5");
|
||||
slint_testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq(instance.get_val(), "Value: 6");
|
||||
```
|
||||
|
||||
```rust
|
||||
let instance = TestCase::new().unwrap();
|
||||
|
||||
assert_eq!(instance.get_val(), "Value: 5");
|
||||
slint_testing::send_mouse_click(&instance, 5., 5.);
|
||||
assert_eq!(instance.get_val(), "Value: 6");
|
||||
```
|
||||
|
||||
```js
|
||||
var instance = new slint.TestCase();
|
||||
|
||||
assert.equal(instance.val, "Value: 5");
|
||||
slintlib.private_api.send_mouse_click(instance, 5., 5.);
|
||||
assert.equal(instance.val, "Value: 6");
|
||||
```
|
||||
*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue