Don't crash in wxGUIEventLoop::Exit() if not running in wxX11.

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
This commit is contained in:
Vadim Zeitlin
2010-11-10 13:53:15 +00:00
parent 04a8da5f57
commit 2c032a5d71

View 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;
}
}
// ----------------------------------------------------------------------------