]> git.saurik.com Git - wxWidgets.git/commitdiff
rolled back exceptions handling patch, it relied on incorrect assumption about vtables
authorVáclav Slavík <vslavik@fastmail.fm>
Tue, 21 Jun 2005 09:56:18 +0000 (09:56 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Tue, 21 Jun 2005 09:56:18 +0000 (09:56 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34721 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/app.h
include/wx/event.h
include/wx/object.h
src/common/appbase.cpp
src/common/appcmn.cpp
src/common/event.cpp
src/msw/evtloop.cpp

index 334c4d7c206ca3ab54e3518cfe0ea70308b63ab0..02c5aee54d3bfee1fada5b7cb6a710af94adaf63 100644 (file)
@@ -433,12 +433,6 @@ public:
         // Perform standard OnIdle behaviour: call from port's OnIdle
     void OnIdle(wxIdleEvent& event);
 
-#if wxUSE_EXCEPTIONS
-    virtual void HandleEvent(wxEvtHandler *handler,
-                             wxEventFunction func,
-                             wxEvent& event) const;
-#endif // wxUSE_EXCEPTIONS
-
 
     // top level window functions
     // --------------------------
index c8dda1ec36f274bf0223d198064830f62abe7a70..2e083e46b51f88da2c5f36baf8068d36e61e7c78 100644 (file)
@@ -2295,8 +2295,6 @@ protected:
 // wxEvtHandler: the base class for all objects handling wxWidgets events
 // ----------------------------------------------------------------------------
 
-typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
-
 class WXDLLIMPEXP_BASE wxEvtHandler : public wxObject
 {
 public:
@@ -2324,15 +2322,6 @@ public:
     bool ProcessThreadEvent(wxEvent& event);
 #endif
 
-#if wxUSE_EXCEPTIONS
-    // call the specified handler with the given event
-    //
-    // this method only exists to allow catching the exceptions thrown by any
-    // event handler, it would lead to an extra (useless) virtual function call
-    // if the exceptions were not used, so it doesn't even exist in that case
-    virtual void DoHandleEvent(wxEventFunction func, wxEvent& event);
-#endif // wxUSE_EXCEPTIONS
-
     // Dynamic association of a member function handler with the event handler,
     // winid and event type
     void Connect(int winid,
@@ -2493,6 +2482,8 @@ inline void wxPostEvent(wxEvtHandler *dest, wxEvent& event)
     dest->AddPendingEvent(event);
 }
 
+typedef void (wxEvtHandler::*wxEventFunction)(wxEvent&);
+
 #define wxEventHandler(func) \
     (wxObjectEventFunction)wxStaticCastEvent(wxEventFunction, &func)
 
index b88a0d850a4fc43b28f9b441143f3c63e8a8d3fa..8f949c0979586d1cfd09edf12400efd918e89511 100644 (file)
 
 class WXDLLIMPEXP_BASE wxObject;
 
-// FIXME: remove in wx-2.7:
-class WXDLLIMPEXP_BASE wxEvent;
-class WXDLLIMPEXP_BASE wxEvtHandler;
-
 #ifndef wxUSE_EXTENDED_RTTI
 #define wxUSE_EXTENDED_RTTI 0
 #endif
@@ -482,9 +478,7 @@ public:
     virtual void ReservedObjectFunc6() {}
     virtual void ReservedObjectFunc7() {}
     virtual void ReservedObjectFunc8() {}
-    // FIXME: turn back into ReservedObjectFunc9() in wx-2.7 (see also FIXME
-    //        near the top of this file)
-    virtual void DoHandleEvent(void (wxEvtHandler::*)(wxEvent&), wxEvent&) {}
+    virtual void ReservedObjectFunc9() {}
 
 protected:
     // ensure that our data is not shared with anybody else: if we have no
index d9f65368b675cc641d8c3ca7ad93d6c9fef24714..0892aab62d0e8724923a18458de698eefa927921 100644 (file)
@@ -316,15 +316,8 @@ wxAppConsole::HandleEvent(wxEvtHandler *handler,
                           wxEventFunction func,
                           wxEvent& event) const
 {
-    // by default, call wxApp::OnExceptionInMainLoop if an exception occurs
-    try
-    {
-        handler->DoHandleEvent(func, event);
-    }
-    catch ( ... )
-    {
-        wxConstCast(this, wxAppConsole)->OnExceptionInMainLoop();
-    }
+    // by default, simply call the handler
+    (handler->*func)(event);
 }
 
 bool
index e5d27ef093e39e55741cace37d8ab5dcada6251d..dddd390ab56bf8192c08b921a46e1e4d46057867 100644 (file)
@@ -46,7 +46,6 @@
 #include "wx/thread.h"
 #include "wx/utils.h"
 #include "wx/ptr_scpd.h"
-#include "wx/evtloop.h"
 
 #if defined(__WXMSW__)
     #include  "wx/msw/private.h"  // includes windows.h for LOGFONT
@@ -468,35 +467,6 @@ void wxAppBase::OnIdle(wxIdleEvent& WXUNUSED(event))
 
 }
 
-// ----------------------------------------------------------------------------
-// exception handling
-// ----------------------------------------------------------------------------
-
-#if wxUSE_EXCEPTIONS
-
-void wxAppBase::HandleEvent(wxEvtHandler *handler,
-                            wxEventFunction func,
-                            wxEvent& event) const
-{
-    // by default, call wxApp::OnExceptionInMainLoop if an exception occurs
-    try
-    {
-        handler->DoHandleEvent(func, event);
-    }
-    catch ( ... )
-    {
-        if ( !wxConstCast(this, wxAppBase)->OnExceptionInMainLoop() )
-        {
-            wxEventLoop *loop = wxEventLoop::GetActive();
-            if ( loop )
-                loop->Exit(-1);
-        }
-        //else: continue running the event loop
-    }
-}
-
-#endif // wxUSE_EXCEPTIONS
-
 // ----------------------------------------------------------------------------
 // wxGUIAppTraitsBase
 // ----------------------------------------------------------------------------
index 648c80e2b78587d4f27d7c892649a432349f5c98..ae6acd19794f2ecc60c08660beed6b94b920cf00 100644 (file)
@@ -1081,14 +1081,6 @@ void wxEvtHandler::ClearEventLocker()
 
 #endif // wxUSE_THREADS
 
-#if wxUSE_EXCEPTIONS
-void wxEvtHandler::DoHandleEvent(wxEventFunction func, wxEvent& event)
-{
-    // by default, just call then handler
-    (this->*func)(event);
-}
-#endif // wxUSE_EXCEPTIONS
-
 void wxEvtHandler::AddPendingEvent(wxEvent& event)
 {
     // 1) Add event to list of pending events of this event handler
index 27877fa3f2fc3b17e7622dcdda256044673a8814..4325bbdd0a33c0c313e8d67986e33d412a84e181 100644 (file)
@@ -207,48 +207,74 @@ int wxEventLoop::Run()
     // should undo
     wxEventLoopActivator activate(&ms_activeLoop, this);
 
+    // we must ensure that OnExit() is called even if an exception is thrown
+    // from inside Dispatch() but we must call it from Exit() in normal
+    // situations because it is supposed to be called synchronously,
+    // wxModalEventLoop depends on this (so we can't just use ON_BLOCK_EXIT or
+    // something similar here)
 #if wxUSE_EXCEPTIONS
-    try
+    for ( ;; )
     {
-#endif
-        // this is the event loop itself
-        for ( ;; )
+        try
         {
-            #if wxUSE_THREADS
-                wxMutexGuiLeaveOrEnter();
-            #endif // wxUSE_THREADS
-
-            // generate and process idle events for as long as we don't
-            // have anything else to do
-            while ( !Pending() && (wxTheApp && wxTheApp->ProcessIdle()) )
-                ;
-
-            // if the "should exit" flag is set, the loop should terminate
-            // but not before processing any remaining messages so while
-            // Pending() returns true, do process them
-            if ( m_shouldExit )
-            {
-                while ( Pending() )
-                    Dispatch();
+#endif // wxUSE_EXCEPTIONS
 
-                break;
+            // this is the event loop itself
+            for ( ;; )
+            {
+                #if wxUSE_THREADS
+                    wxMutexGuiLeaveOrEnter();
+                #endif // wxUSE_THREADS
+
+                // generate and process idle events for as long as we don't
+                // have anything else to do
+                while ( !Pending() && (wxTheApp && wxTheApp->ProcessIdle()) )
+                    ;
+
+                // if the "should exit" flag is set, the loop should terminate
+                // but not before processing any remaining messages so while
+                // Pending() returns true, do process them
+                if ( m_shouldExit )
+                {
+                    while ( Pending() )
+                        Dispatch();
+
+                    break;
+                }
+
+                // a message came or no more idle processing to do, sit in
+                // Dispatch() waiting for the next message
+                if ( !Dispatch() )
+                {
+                    // we got WM_QUIT
+                    break;
+                }
             }
 
-            // a message came or no more idle processing to do, sit in
-            // Dispatch() waiting for the next message
-            if ( !Dispatch() )
+#if wxUSE_EXCEPTIONS
+            // exit the outer loop as well
+            break;
+        }
+        catch ( ... )
+        {
+            try
+            {
+                if ( !wxTheApp || !wxTheApp->OnExceptionInMainLoop() )
+                {
+                    OnExit();
+                    break;
+                }
+                //else: continue running the event loop
+            }
+            catch ( ... )
             {
-                // we got WM_QUIT
-                break;
+                // OnException() throwed, possibly rethrowing the same
+                // exception again: very good, but we still need OnExit() to
+                // be called
+                OnExit();
+                throw;
             }
         }
-#if wxUSE_EXCEPTIONS
-    }
-    catch ( ... )
-    {
-        // we need OnExit() to be called before the event loop stops
-        OnExit();
-        throw;
     }
 #endif // wxUSE_EXCEPTIONS