bool MainWindow::RequestStop() { if (!Core::IsRunning()) { Core::QueueHostJob([this] { OnStopComplete(); }, true); return true; } if (SConfig::GetInstance().bConfirmStop) { const Core::State state = Core::GetState(); // Only pause the game, if NetPlay is not running bool pause = Settings::Instance().GetNetPlayClient() != nullptr; if (pause) Core::SetState(Core::State::Paused); QMessageBox::StandardButton confirm; confirm = QMessageBox::question(m_render_widget, tr("Confirm"), m_stop_requested ? tr("A shutdown is already in progress. Unsaved data " "may be lost if you stop the current emulation " "before it completes. Force stop?") : tr("Do you want to stop the current emulation?")); if (pause) Core::SetState(state); if (confirm != QMessageBox::Yes) return false; } // TODO: Add Movie shutdown // TODO: Add Debugger shutdown if (!m_stop_requested && UICommon::TriggerSTMPowerEvent()) { m_stop_requested = true; // Unpause because gracefully shutting down needs the game to actually request a shutdown. // TODO: Do not unpause in debug mode to allow debugging until the complete shutdown. if (Core::GetState() == Core::State::Paused) Core::SetState(Core::State::Running); return true; } ForceStop(); #ifdef Q_OS_WIN // Allow windows to idle or turn off display again SetThreadExecutionState(ES_CONTINUOUS); #endif return true; }
bool MainWindow::Stop() { bool stop = true; if (Settings().GetConfirmStop()) { // We could pause the game here and resume it if they say no. QMessageBox::StandardButton confirm; confirm = QMessageBox::question(m_render_widget, tr("Confirm"), tr("Stop emulation?")); stop = (confirm == QMessageBox::Yes); } if (stop) ForceStop(); return stop; }
bool CThread::WaitTimeout(unsigned long ulTimeout,int iStopMode) { unsigned long ulCount=ulTimeout; //Wait until the end of the thread or the timeout while(IsRunning() && ulCount>0) { SleepMillisecs(1000); ulCount--; } /* iStopMode : 0 = do not stop the thread after timeout 1 = request the thread o stop after timeout 2 = force the thread to stop */ if(IsRunning()) { switch(iStopMode) { case 1: RequestStop(); break; case 2: ForceStop(); break; default: break; } return false; } else { return true; } }
ECThread::~ECThread() { ForceStop(); }