slint/tests/cases/models/indirect_model_changes.slint
Olivier Goffart 94af4d2832 Don't optimize array
They are model and if the model is copied, the changes in model need to
apply to all copies.

Fixes #5249
2024-06-04 15:24:36 +02:00

61 lines
1.2 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
component IndirectChange {
in property <[int]> mod;
property <[int]> private: mod;
init => {
private[0] += 1;
}
}
export component TestCase {
property <[int]> m1: [5];
property <[int]> m2: [8];
property <[int]> indirect: m2;
public function up() {
indirect[0] += 10;
}
callback up2();
up2 => {up()}
IndirectChange { mod: m1; }
out property <int> t1: m1[0];
out property <int> t2: m2[0];
out property <bool> test: t1 == 5+1 && t2 == 8;
}
/*
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert_eq(instance.get_t1(), 6);
assert(instance.get_test());
instance.invoke_up();
assert_eq(instance.get_t2(), 18);
```
```rust
let instance = TestCase::new().unwrap();
assert_eq!(instance.get_t1(), 6);
assert!(instance.get_test());
instance.invoke_up();
assert_eq!(instance.get_t2(), 18);
```
```js
var instance = new slint.TestCase({});
assert.equal(instance.t1, 6);
assert(instance.test);
instance.up2();
assert.equal(instance.t2, 18);
```
*/