slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.55k stars 601 forks source link

Can't set array property in function slint::invoke_from_event_loop #4523

Closed tao-a-man closed 9 months ago

tao-a-man commented 9 months ago

hii Slint team, I have a issue when i try set a property is array in function slint::invoke_from_event_loop (picture 2), This error make IOT app crash (picture 1) Screenshot 2024-02-02 142415 ) Screenshot 2024-02-02 142314

tao-a-man commented 9 months ago

hii @ogoffart have a nice day Sir, plss help me check this case if i set array property ListNodeEnabel by ui->set_ListNodeEnabel(nodelists) everythings oke but UI not re-render, then i set array property ListNodeEnabel as above I get issue :(((, I declare ListNodeEnabel like in-out property <[INode]> ListNodeEnabel;

tronical commented 9 months ago

In your lambda, it looks like you're capturing nodelists by reference (&), which means that if by the time the lambda is invoked, you'll get a crash when nodelists is already out of scope and destroyed. Maybe you want to capture it by value, explicitly? ([nodelists, ui = slint::ComponentWeakHandle(ui)] { ... })

tronical commented 9 months ago

I'm closing this as it's not evident that this is a bug. Happy to re-open if it turns out to be a Slint issue :)

tao-a-man commented 9 months ago

It worked Sir thank you for help, I really respect that ❤️