Closed danutsu closed 3 days ago
As a note: building/running the above code locally, in Rust, works fine, so it seems to be a slintpad issue.
Thanks for filling a bug. This can be reproduced with the Slint viewer.
thread 'main' panicked at internal/interpreter/eval.rs:1541:49:
called `Result::unwrap()` on an `Err` value: ()
...
4: slint_interpreter::eval::new_struct_with_bindings
at ./internal/interpreter/eval.rs:1541:13
5: slint_interpreter::dynamic_item_tree::animation_for_property
at ./internal/interpreter/dynamic_item_tree.rs:1236:44
6: slint_interpreter::dynamic_item_tree::instantiate::{{closure}}
at ./internal/interpreter/dynamic_item_tree.rs:1473:39
7: i_slint_compiler::generator::handle_property_bindings_init::handle_property_inner
at ./internal/compiler/generator.rs:433:9
Even more reduced testcase:
export component Demo {
for d in [8s]: TouchArea {
property <float> progress: 0.0;
function set() {
progress = 1
}
animate progress { duration: d; }
}
}
I investigated the issue. The problem is that the bindings for animated property are read when the itemtree is instentiated. (Because of issue #348)
And in this case, we are reading the model data before it's been set in the update call, so it still has a value of Value::Void
and we panic as that's not the correct type for a duration.
On Slintpad, paste the following code:
Expected: works fine and one animated spinner is displayed. Actual: preview UI freezes with "Updating preview..." and console is full of errors like:
It has something to do with the binding: if you replace
d.dur
in theduration
line with1s
it previews fine.