X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c738d187e9af897f9540b30e7e46f4e496dd5754..cc4d5638c66a409e421420ed7110917755a66788:/src/gtk1/evtloop.cpp diff --git a/src/gtk1/evtloop.cpp b/src/gtk1/evtloop.cpp index 5f4a91f995..39f129b610 100644 --- a/src/gtk1/evtloop.cpp +++ b/src/gtk1/evtloop.cpp @@ -4,7 +4,6 @@ // Author: Vadim Zeitlin // Modified by: // Created: 10.07.01 -// RCS-ID: $Id$ // Copyright: (c) 2001 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -69,7 +68,27 @@ int wxGUIEventLoop::DoRun() { m_impl = new wxEventLoopImpl; - gtk_main(); + guint loopLevel = gtk_main_level(); + + // This is placed inside of a loop to take into account nested + // event loops. For example, inside this event loop, we may recieve + // Exit() for a different event loop (which we are currently inside of) + // That Exit() will cause this gtk_main() to exit so we need to re-enter it. + while ( !m_shouldExit ) + { + gtk_main(); + } + + // Force the enclosing event loop to also exit to see if it is done + // in case that event loop ended inside of this one. If it is not time + // yet for that event loop to exit, it will be executed again due to + // the while() loop on m_shouldExit(). + // + // This is unnecessary if we are the top level loop, i.e. loop of level 0. + if ( loopLevel ) + { + gtk_main_quit(); + } OnExit(); @@ -79,12 +98,14 @@ int wxGUIEventLoop::DoRun() return exitcode; } -void wxGUIEventLoop::Exit(int rc) +void wxGUIEventLoop::ScheduleExit(int rc) { - wxCHECK_RET( IsRunning(), wxT("can't call Exit() if not running") ); + wxCHECK_RET( IsInsideRun(), wxT("can't call ScheduleExit() if not started") ); m_impl->SetExitCode(rc); + m_shouldExit = true; + gtk_main_quit(); }