forked from slint-ui/slint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix const detection with two ways binding
The const detection for two way binding was not detecting change if one of the property was set to a const value in a component using it. This would cause the compiler to generate call set_content on one of the property in a two way bindings, and later, the "const sentinel" be present in the dependency list, causing crash. To avoid segfault for similar bug in the future, added added an assert! in the property system to detect that. Fixes slint-ui#2185
- Loading branch information
Showing
3 changed files
with
81 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
tests/cases/bindings/change_sub_property_indirection_issue2185.slint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright © SixtyFPS GmbH <info@slint-ui.com> | ||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial | ||
|
||
component Buggy { | ||
in-out property<string> magic: "Nope"; | ||
property<bool> condition: false; | ||
|
||
public function change_condition() { | ||
condition = !condition; | ||
} | ||
|
||
HorizontalLayout { | ||
if root.condition: TouchArea { | ||
property <string> innermagic <=> root.magic; | ||
clicked => { self.innermagic = "Hello"; } | ||
horizontal-stretch: 1; | ||
} | ||
|
||
Rectangle { | ||
background: red; | ||
TouchArea { | ||
clicked => { change-condition() } | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
component TestCase { | ||
width: 300px; | ||
height: 100px; | ||
|
||
public function change_condition() { | ||
b.change-condition(); | ||
} | ||
|
||
b := Buggy { | ||
magic: "Hi"; | ||
} | ||
|
||
out property <string> magic: b.magic; | ||
} | ||
|
||
|
||
/* | ||
```rust | ||
let instance = TestCase::new(); | ||
assert_eq!(instance.get_magic(), slint::SharedString::from("Hi")); | ||
instance.invoke_change_condition(); | ||
instance.invoke_change_condition(); | ||
instance.invoke_change_condition(); | ||
assert_eq!(instance.get_magic(), slint::SharedString::from("Hi")); | ||
slint_testing::send_mouse_click(&instance, 10., 10.); | ||
assert_eq!(instance.get_magic(), slint::SharedString::from("Hello")); | ||
``` | ||
*/ |