Qt: Ensure system is shut down before closing

Fixes crash on shutdown on Mac.
This commit is contained in:
Stenzek
2023-02-05 13:43:00 +10:00
parent 1371dcfa4a
commit 0ef24398f8
9 changed files with 50 additions and 40 deletions

View File

@@ -981,11 +981,11 @@ std::optional<WindowInfo> Host::GetTopLevelWindowInfo()
return g_nogui_window->GetPlatformWindowInfo();
}
void Host::RequestExit(bool save_state_if_running)
void Host::RequestExit(bool allow_confirm)
{
if (System::IsValid())
{
Host::RunOnCPUThread([save_state_if_running]() { System::ShutdownSystem(save_state_if_running); });
Host::RunOnCPUThread([]() { System::ShutdownSystem(g_settings.save_state_on_exit); });
}
// clear the running flag, this'll break out of the main CPU loop once the VM is shutdown.
@@ -1022,7 +1022,7 @@ static void SignalHandler(int signal)
{
std::fprintf(stderr, "Received CTRL+C, attempting graceful shutdown. Press CTRL+C again to force.\n");
graceful_shutdown_attempted = true;
Host::RequestExit(true);
Host::RequestExit(false);
return;
}

View File

@@ -270,7 +270,7 @@ void WaylandNoGUIPlatform::TopLevelConfigure(void* data, struct xdg_toplevel* xd
void WaylandNoGUIPlatform::TopLevelClose(void* data, struct xdg_toplevel* xdg_toplevel)
{
Host::RunOnCPUThread([]() { Host::RequestExit(g_settings.save_state_on_exit); });
Host::RunOnCPUThread([]() { Host::RequestExit(false); });
}
void WaylandNoGUIPlatform::SeatCapabilities(void* data, wl_seat* seat, uint32_t capabilities)

View File

@@ -399,7 +399,8 @@ LRESULT CALLBACK Win32NoGUIPlatform::WndProc(HWND hwnd, UINT msg, WPARAM wParam,
case WM_CLOSE:
case WM_QUIT:
{
Host::RunOnCPUThread([]() { Host::RequestExit(g_settings.save_state_on_exit); });
Host::RunOnCPUThread([]() { Host::RequestExit(false); });
return 0;
}
break;

View File

@@ -233,7 +233,7 @@ void X11NoGUIPlatform::ProcessXEvents()
case ClientMessage:
{
if (static_cast<Atom>(event.xclient.data.l[0]) == XInternAtom(m_display, "WM_DELETE_WINDOW", False))
Host::RequestExit(true);
Host::RequestExit(false);
}
break;