]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/event.cpp
Derive from wxToggleButtonBase
[wxWidgets.git] / src / common / event.cpp
index 5654a132fbae6b9382200e6b45a36b12f970d309..c6943ad14e306bc8253eb34451d8946a53315864 100644 (file)
@@ -25,6 +25,7 @@
 #endif
 
 #include "wx/event.h"
+#include "wx/evtloop.h"
 
 #ifndef WX_PRECOMP
     #include "wx/list.h"
@@ -42,6 +43,8 @@
     #endif // wxUSE_GUI
 #endif
 
+#include "wx/thread.h"
+
 // ----------------------------------------------------------------------------
 // wxWin macros
 // ----------------------------------------------------------------------------
@@ -1314,6 +1317,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)
 {