Exception during Eto button-click causes application freeze

Hi all,

I just wanted to note some unpleasant behavior I’ve noticed while writing Eto windows using the Rhino Python Editor (on both Windows OS and MacOS). I have found that if an Exception is thrown as the result of button press, (just as an example, using the template script but adding a raise exception call when you click ‘Ok’ ) :

You get a warning window from Rhino, as expected:

but as soon as you click ‘OK’, you get stuck without any way to recover:

  1. If you click Ok in the custom Eto window a second time, the entire Application crashes.
  2. If you click either the Cancel button in the Eto window, or the ‘Close Window’ button in the title bar, everything seems to get ‘stuck’. All the Rhino application commands go greyed out, and you cannot do anything except force-quite the entire application.

This is the case for both the Python editor window, as well as the main Rhino window:

I feel like this is not appropriate behavior. Its not that uncommon to get exceptions every once and while when developing windows and plugins, and I think it is a real drag to have to close the entire application every time you accidentally add a syntax error within some command.

Is there a way to avoid / fix this so that simple exceptions can get handled without crashing the entire App? Is there a code pattern that I should be using for these Eto dialogs to improve resilience? Nesting everything inside try...except blocks seems less than ideal, and also doesn’t really seem to fix the issue?

thanks very much,

Hey @ed.p.may,

There’s no real way for us to add an implicit try/catch around all your event handlers, unless @Alain has some ideas. Your only real option here is to always add a try...except block when handling UI events. This is true for all UI toolkits and most all events, not just Eto.

Hope this helps!

Hi @curtisw ,

Thanks very much for weighing in - I appreciate the input.

I should have explained a little better: this actually all works ok on WindowsOS, its only on MacOS that you get ‘stuck’ like I described above. If I run the exact same script with the Exception inside the button click, I do get the an error of course, but if you then just click the window ‘close’ button (not the ‘cancel’, only click the ‘close’) you do not get stuck without the ability to save, edit, or re-run:

click ‘close window’ and the Rhino app comes back to life:

whereas on the MacOS, when you do the exact same thing all the application commands go grey and you can’t save, edit, re-run or close the app. You have to force quite to escape.

I guess I would just hope that on MacOS we’d get the same behavior: the ability to carry on, edit, save, etc… after an exception gets thrown? Or maybe there is some easy way (some key command?) to get the application back that I don’t know of after an exception is raised?

Hope that makes sense. Thanks so much!