diff --git a/internal/core/properties.rs b/internal/core/properties.rs index 752b490398e..317fe9c92bb 100644 --- a/internal/core/properties.rs +++ b/internal/core/properties.rs @@ -1175,7 +1175,6 @@ impl Property { } common_property }; - prop2.handle.remove_binding(); Self::link_two_way_with_map_to_common_property(common_property, prop2, map_to, map_from); } diff --git a/tests/cases/bindings/two_way_binding_structs2.slint b/tests/cases/bindings/two_way_binding_structs2.slint new file mode 100644 index 00000000000..e21d3d434e9 --- /dev/null +++ b/tests/cases/bindings/two_way_binding_structs2.slint @@ -0,0 +1,59 @@ +// Copyright © SixtyFPS GmbH +// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 + +// FIXME: only works with rust +//ignore: cpp,interpreter,js + + +component Link { + in-out property str1: "XXX"; + in-out property str2 <=> str1; +} + +struct S1 { + s1: string, + i1: int, +} + +struct S2 { + f2: float, + s2: string, +} + +export component TestCase inherits Window { + in-out property s1: { s1: "s1", i1: 8 }; + in-out property s2: { f2: 4.1, s2: "s2" }; + Link { + str1 <=> s1.s1; + str2 <=> s2.s2; + } + out property test: s1.s1 == s2.s2; +} + + +/* + +```rust +let instance = TestCase::new().unwrap(); +assert!(instance.get_test()); +instance.set_s1(S1{ s1: "s1-changed".into(), i1: 89 }); +assert_eq!(instance.get_s2(), S2{ s2: "s1-changed".into(), f2: 4.1 }); +instance.set_s2(S2{ s2: "s2-changed".into(), f2: 4.2 }); +assert_eq!(instance.get_s1(), S1{ s1: "s2-changed".into(), i1: 89 }); +``` + + + +```cpp +auto handle = TestCase::create(); +const TestCase &instance = *handle; +assert(instance.get_test()); +``` + + +```js +let instance = new slint.TestCase({}); +assert(instance.test); +``` + +*/