gtk-rs / examples

DEPRECATED, use https://github.com/gtk-rs/gtk-rs repository instead!
MIT License
283 stars 76 forks source link

Come up with a way to handle panics #324

Open YaLTeR opened 3 years ago

YaLTeR commented 3 years ago

An example application that shows an error dialog with a backtrace and exits when a panic occurs within GUI code.

This is an issue I've been thinking about for some time and couldn't come up with an obvious solution for. It's unreasonable to forbid panics, but it's bad UX when the application inexplicably closes.

The problem is further complicated by the fact that the panic could occur in odd places such as GObject methods (constructed, etc.) and callbacks on another thread.

Since currently unwinding through C frames (GTK included) is undefined, an approach that comes to mind is to show a blocking dialog from within the panic hook and then abort once the dialog is closed. I'm not familiar enough with GTK to know if that can be done though. How do other languages handle critical errors in GTK applications?