mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
Merge pull request #4244 from leoetlino/stm-shutdown
Shut down Wii software gracefully
This commit is contained in:
@ -158,6 +158,7 @@ private:
|
||||
bool m_bGameLoading = false;
|
||||
bool m_bClosing = false;
|
||||
bool m_confirmStop = false;
|
||||
bool m_tried_graceful_shutdown = false;
|
||||
int m_saveSlot = 1;
|
||||
|
||||
std::vector<std::string> drives;
|
||||
|
@ -1148,9 +1148,12 @@ void CFrame::DoStop()
|
||||
Core::SetState(Core::CORE_PAUSE);
|
||||
}
|
||||
|
||||
wxMessageDialog m_StopDlg(this, _("Do you want to stop the current emulation?"),
|
||||
_("Please confirm..."),
|
||||
wxYES_NO | wxSTAY_ON_TOP | wxICON_EXCLAMATION, wxDefaultPosition);
|
||||
wxMessageDialog m_StopDlg(
|
||||
this, !m_tried_graceful_shutdown ? _("Do you want to stop the current emulation?") :
|
||||
_("A shutdown is already in progress. Unsaved data "
|
||||
"may be lost if you stop the current emulation "
|
||||
"before it completes. Force stop?"),
|
||||
_("Please confirm..."), wxYES_NO | wxSTAY_ON_TOP | wxICON_EXCLAMATION, wxDefaultPosition);
|
||||
|
||||
HotkeyManagerEmu::Enable(false);
|
||||
int Ret = m_StopDlg.ShowModal();
|
||||
@ -1165,6 +1168,16 @@ void CFrame::DoStop()
|
||||
}
|
||||
}
|
||||
|
||||
if (SConfig::GetInstance().bWii && !m_tried_graceful_shutdown)
|
||||
{
|
||||
Core::DisplayMessage("Shutting down", 30000);
|
||||
Core::SetState(Core::CORE_RUN);
|
||||
ProcessorInterface::PowerButton_Tap();
|
||||
m_confirmStop = false;
|
||||
m_tried_graceful_shutdown = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (UseDebugger && g_pCodeWindow)
|
||||
{
|
||||
if (g_pCodeWindow->m_WatchWindow)
|
||||
@ -1200,6 +1213,7 @@ void CFrame::DoStop()
|
||||
void CFrame::OnStopped()
|
||||
{
|
||||
m_confirmStop = false;
|
||||
m_tried_graceful_shutdown = false;
|
||||
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
if (SConfig::GetInstance().bDisableScreenSaver)
|
||||
|
@ -34,6 +34,8 @@
|
||||
static bool rendererHasFocus = true;
|
||||
static bool rendererIsFullscreen = false;
|
||||
static Common::Flag s_running{true};
|
||||
static Common::Flag s_shutdown_requested{false};
|
||||
static Common::Flag s_tried_graceful_shutdown{false};
|
||||
|
||||
static void signal_handler(int)
|
||||
{
|
||||
@ -41,7 +43,12 @@ static void signal_handler(int)
|
||||
if (write(STDERR_FILENO, message, sizeof(message)) < 0)
|
||||
{
|
||||
}
|
||||
s_running.Clear();
|
||||
s_shutdown_requested.Set();
|
||||
}
|
||||
|
||||
namespace ProcessorInterface
|
||||
{
|
||||
void PowerButton_Tap();
|
||||
}
|
||||
|
||||
class Platform
|
||||
@ -222,6 +229,19 @@ class PlatformX11 : public Platform
|
||||
// The actual loop
|
||||
while (s_running.IsSet())
|
||||
{
|
||||
if (s_shutdown_requested.TestAndClear())
|
||||
{
|
||||
if (!s_tried_graceful_shutdown.IsSet() && SConfig::GetInstance().bWii)
|
||||
{
|
||||
ProcessorInterface::PowerButton_Tap();
|
||||
s_tried_graceful_shutdown.Set();
|
||||
}
|
||||
else
|
||||
{
|
||||
s_running.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
XEvent event;
|
||||
KeySym key;
|
||||
for (int num_events = XPending(dpy); num_events > 0; num_events--)
|
||||
@ -286,7 +306,7 @@ class PlatformX11 : public Platform
|
||||
break;
|
||||
case ClientMessage:
|
||||
if ((unsigned long)event.xclient.data.l[0] == XInternAtom(dpy, "WM_DELETE_WINDOW", False))
|
||||
s_running.Clear();
|
||||
s_shutdown_requested.Set();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -375,6 +395,7 @@ int main(int argc, char* argv[])
|
||||
UICommon::SetUserDirectory(""); // Auto-detect user folder
|
||||
UICommon::Init();
|
||||
|
||||
Core::SetOnStoppedCallback([]() { s_running.Clear(); });
|
||||
platform->Init();
|
||||
|
||||
// Shut down cleanly on SIGINT and SIGTERM
|
||||
|
Reference in New Issue
Block a user