Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window component should have destroying/being-destroyed callback #6670

Open
Enyium opened this issue Oct 28, 2024 · 1 comment
Open

Window component should have destroying/being-destroyed callback #6670

Enyium opened this issue Oct 28, 2024 · 1 comment
Labels
needs info Further information from the reporter is requested

Comments

@Enyium
Copy link
Contributor

Enyium commented Oct 28, 2024

You should be able to run final .slint code, like taking data from the UI, before your app (or just window) is shut down. This is similar to #6401, but would allow to run code unconditionally, no matter whether the end user closed the window in question, or it was programmatically hidden and is subsequently being destroyed.

Maybe, this would require hide() to start behaving differently, namely to only destroy the internal strong reference in a closure enqueued in the event loop. This could be desirable anyways. Like with quit_event_loop() (see also #6562), it can be useful to enqueue actions in the event loop using invoke_from_event_loop(), and then call hide() and/or quit_event_loop(), without the window having been destroyed before the actions ran. This would make Slint's behavior much more predictable.

With the behavior as it currently is, you're required to jump through hoops (that I didn't figure out at the time of writing) to get .slint code to run before the window is destroyed on hide(), at least in certain app designs where your holding onto the component doesn't span the runs of the closures sent via invoke_from_event_loop(). With an app design utilizing RefCell, you can definitely not simply synchronously invoke_...() a .slint function that calls back to Rust, but need to wrap that in invoke_from_event_loop(), because you can get RefCell panics that way. But that execution will then be too late.

@FloVanGH FloVanGH added the need triaging Issue that the owner of the area still need to triage label Oct 28, 2024
@ogoffart
Copy link
Member

Could you elaborate a bit more the use case?
Why is on_close_requested not sufficient?

@ogoffart ogoffart added needs info Further information from the reporter is requested and removed need triaging Issue that the owner of the area still need to triage labels Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs info Further information from the reporter is requested
Projects
None yet
Development

No branches or pull requests

3 participants