Add wxApp::StoreCurrentException() and RethrowStoredException().
These methods can be used to ensure that the exceptions thrown from event handlers are safely rethrown from the code dispatching the events once the control flow gets back there. This allows to work around the problem with not being able to propagate exceptions through non-C++ code and can be used, for example, to catch exceptions thrown by the handlers invoked from inside wxYield() by a try/catch block around wxYield() -- something that didn't work before, update the except sample to show that it does work now. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77468 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -298,10 +298,24 @@ public:
|
||||
|
||||
// Function called if an uncaught exception is caught inside the main
|
||||
// event loop: it may return true to continue running the event loop or
|
||||
// false to stop it (in the latter case it may rethrow the exception as
|
||||
// well)
|
||||
// false to stop it. If this function rethrows the exception, as it does by
|
||||
// default, simply because there is no general way to handle exceptions,
|
||||
// StoreCurrentException() will be called to store it because in any case
|
||||
// the exception can't be allowed to escape.
|
||||
virtual bool OnExceptionInMainLoop();
|
||||
|
||||
// This function can be overridden to store the current exception, in view
|
||||
// of rethrowing it later when RethrowStoredException() is called. If the
|
||||
// exception was stored, return true. The default implementation returns
|
||||
// false, indicating that the exception wasn't stored and that the program
|
||||
// should be simply aborted.
|
||||
virtual bool StoreCurrentException();
|
||||
|
||||
// If StoreCurrentException() is overridden, this function should be
|
||||
// overridden as well to rethrow the exceptions stored by it when the
|
||||
// control gets back to our code, i.e. when it's safe to do it. The default
|
||||
// version does nothing.
|
||||
virtual void RethrowStoredException() { }
|
||||
#endif // wxUSE_EXCEPTIONS
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user