void wxGUIEventLoop::ScheduleExit(int rc) { wxCHECK_RET( IsInsideRun(), wxT("can't call ScheduleExit() if not started") ); m_exitcode = rc; m_shouldExit = true; gtk_main_quit(); }
// sets the "should exit" flag and wakes up the loop so that it terminates // soon void ScheduleExit( int rc = 0 ) { wxCHECK_RET( IsInsideRun(), wxT("can't call ScheduleExit() if not running") ); m_exitcode = rc; m_shouldExit = true; OnExit(); // all we have to do to exit from the loop is to (maybe) wake it up so that // it can notice that Exit() had been called // // in particular, do *not* use here calls such as PostQuitMessage() (under // MSW) which terminate the current event loop here because we're not sure // that it is going to be processed by the correct event loop: it would be // possible that another one is started and terminated by mistake if we do // this WakeUp(); }
int wxEventLoopBase::Run() { // event loops are not recursive, you need to create another loop! wxCHECK_MSG( !IsInsideRun(), -1, wxT("can't reenter a message loop") ); // ProcessIdle() and ProcessEvents() below may throw so the code here should // be exception-safe, hence we must use local objects for all actions we // should undo wxEventLoopActivator activate(this); // We might be called again, after a previous call to ScheduleExit(), so // reset this flag. m_shouldExit = false; // Set this variable to true for the duration of this method. m_isInsideRun = true; wxON_BLOCK_EXIT_SET(m_isInsideRun, false); // Finally really run the loop. return DoRun(); }
void wxQtEventLoopBase::ScheduleExit(int rc) { wxCHECK_RET( IsInsideRun(), wxT("can't call ScheduleExit() if not started") ); m_shouldExit = true; QCoreApplication::exit( rc ); }