]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/event.cpp
fixing new inheritance
[wxWidgets.git] / src / common / event.cpp
index 5654a132fbae6b9382200e6b45a36b12f970d309..0b196d5d72dac8bc42086d0619f80298019ff0ba 100644 (file)
@@ -25,6 +25,7 @@
 #endif
 
 #include "wx/event.h"
+#include "wx/evtloop.h"
 
 #ifndef WX_PRECOMP
     #include "wx/list.h"
@@ -1314,6 +1315,42 @@ bool wxEvtHandler::ProcessEvent(wxEvent& event)
     return TryParent(event);
 }
 
+bool wxEvtHandler::SafelyProcessEvent(wxEvent& event)
+{
+#if wxUSE_EXCEPTIONS
+    try
+    {
+#endif
+        return ProcessEvent(event);
+#if wxUSE_EXCEPTIONS
+    }
+    catch ( ... )
+    {
+        wxEventLoopBase *loop = wxEventLoopBase::GetActive();
+        try
+        {
+            if ( !wxTheApp || !wxTheApp->OnExceptionInMainLoop() )
+            {
+                if ( loop )
+                    loop->Exit();
+            }
+            //else: continue running current event loop
+
+            return false;
+        }
+        catch ( ... )
+        {
+            // OnExceptionInMainLoop() threw, possibly rethrowing the same
+            // exception again: very good, but we still need Exit() to
+            // be called
+            if ( loop )
+                loop->Exit();
+            throw;
+        }
+    }
+#endif // wxUSE_EXCEPTIONS
+}
+
 
 bool wxEvtHandler::SearchEventTable(wxEventTable& table, wxEvent& event)
 {