]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/evtloop.cpp
added wxGzipIOStreams (patch 792932)
[wxWidgets.git] / src / msw / evtloop.cpp
index c2540c8ee913daae1d97d5ca1b884502f3b2c616..6c7e74c00ff73d6b30bd763c389c84c00974437b 100644 (file)
@@ -38,7 +38,6 @@
 #include "wx/tooltip.h"
 #include "wx/except.h"
 #include "wx/ptr_scpd.h"
-#include "wx/scopeguard.h"
 
 #include "wx/msw/private.h"
 
@@ -241,27 +240,34 @@ int wxEventLoop::Run()
     wxEventLoopActivator activate(&ms_activeLoop, this);
     wxEventLoopImplTiedPtr impl(&m_impl, new wxEventLoopImpl);
 
-    wxON_BLOCK_EXIT_OBJ0(*this, &wxEventLoop::OnExit);
-
-    for ( ;; )
+    // 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)
+    wxTRY
     {
+        for ( ;; )
+        {
 #if wxUSE_THREADS
-        wxMutexGuiLeaveOrEnter();
+            wxMutexGuiLeaveOrEnter();
 #endif // wxUSE_THREADS
 
-        // generate and process idle events for as long as we don't have
-        // anything else to do
-        while ( !Pending() && m_impl->SendIdleMessage() )
-            ;
+            // generate and process idle events for as long as we don't have
+            // anything else to do
+            while ( !Pending() && m_impl->SendIdleMessage() )
+                ;
 
-        // 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() )
+            {
+                // we got WM_QUIT
+                break;
+            }
         }
     }
+    wxCATCH_ALL( OnExit(); )
 
     return m_impl->GetExitCode();
 }
@@ -272,6 +278,8 @@ void wxEventLoop::Exit(int rc)
 
     m_impl->SetExitCode(rc);
 
+    OnExit();
+
     ::PostQuitMessage(rc);
 }