]> git.saurik.com Git - wxWidgets.git/commitdiff
Don't crash in wxGUIEventLoop::Exit() if not running in wxX11.
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 10 Nov 2010 13:53:15 +0000 (13:53 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 10 Nov 2010 13:53:15 +0000 (13:53 +0000)
The implementation of wxEventLoop::IsRunning() has changed since this code was
written and it doesn't check for m_impl != NULL any more. Because of this,
calling Exit() for an active but not running event loop resulted in a crash in
wxX11.

Fix this by doing nothing in this case. This seems better than asserting as
the event handling code exits the loop if an event handler throws an exception
and the loop might not be running in this case yet (events could be processed
because of a wxYield() call).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66098 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/x11/evtloop.cpp

index 2c78103d9ab77973112bafb68556156e313579ec..146fabde1495ee8ff7e83f2f27e7060643011c48 100644 (file)
@@ -128,7 +128,7 @@ wxGUIEventLoop::~wxGUIEventLoop()
 int wxGUIEventLoop::Run()
 {
     // event loops are not recursive, you need to create another loop!
-    wxCHECK_MSG( !IsRunning(), -1, wxT("can't reenter a message loop") );
+    wxCHECK_MSG( !m_impl, -1, wxT("can't reenter a message loop") );
 
     m_impl = new wxEventLoopImpl;
 
@@ -169,10 +169,11 @@ int wxGUIEventLoop::Run()
 
 void wxGUIEventLoop::Exit(int rc)
 {
-    wxCHECK_RET( IsRunning(), wxT("can't call Exit() if not running") );
-
-    m_impl->SetExitCode(rc);
-    m_impl->m_keepGoing = false;
+    if ( m_impl )
+    {
+        m_impl->SetExitCode(rc);
+        m_impl->m_keepGoing = false;
+    }
 }
 
 // ----------------------------------------------------------------------------