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.72k stars 615 forks source link

Live preview always crashes on MacOS when closed with CMD + q #5962

Closed NigelBreslaw closed 3 months ago

NigelBreslaw commented 3 months ago

It's pretty normal to quit running windows on Mac this way and a surprise to see the crash message.

ogoffart commented 3 months ago

Caused by https://github.com/slint-ui/slint/issues/4482

tronical commented 3 months ago

So there's no way to intercept this AFAICS. Winit calls terminate unconditionalyl and that's it. I think the best we can do at this point is to not detect this as a crash and quietly restart the lsp - at least within vscode.

ogoffart commented 3 months ago

Can we fix or fill an issue in winit to make this behavior configurable?

tronical commented 3 months ago

I don't think we should file an issue with winit to change the behaviour of the "Quit " menu item to not call terminate. That menu is a stop-gap and for example it suffers from the inability to translate the menu entries.

I think we should close https://github.com/slint-ui/slint/issues/4482 as wont fix and implement #38 instead, which permits the user to handle this cleanly.

For this issue here, I suggest to work around it in the preview. Easiest would be to disable the system menu (with_default_menu(false)). That's I think strictly speaking a violation of the HIG. So if that's not acceptable, then we could just implement our own macOS menu with a little platform specific code until #38 is done. @nigel how bad do you think it would be not to have the menu (and thus shortcut) for the slint live-preview window?

NigelBreslaw commented 3 months ago

Not sure what I am being asked. I don't care about the menu, but I need a keyboard shortcut to restart the preview. I guess another stop gap is a button in the UI that you have to click, but that does seem a pain to force mouse use.

tronical commented 3 months ago

You've answered my question - thanks ;-). I'll make a patch to remove the menu (and shortcut) for the Live-Preview.