fix(ui): Improper Overlay Shutdown & Zombie Processes

Signed-off-by: Collecting <collecting@noreply.localhost>
This commit is contained in:
Collecting
2026-01-08 07:15:32 +00:00
parent 3de27e989a
commit 7087f324f5

View File

@@ -343,8 +343,10 @@ bool GMainWindow::CheckDarkMode() {
} }
GMainWindow::GMainWindow(std::unique_ptr<QtConfig> config_, bool has_broken_vulkan) GMainWindow::GMainWindow(std::unique_ptr<QtConfig> config_, bool has_broken_vulkan)
: ui{std::make_unique<Ui::MainWindow>()}, system{std::make_unique<Core::System>()}, : system{std::make_unique<Core::System>()},
input_subsystem{std::make_shared<InputCommon::InputSubsystem>()}, config{std::move(config_)}, input_subsystem{std::make_shared<InputCommon::InputSubsystem>()},
ui{std::make_unique<Ui::MainWindow>()},
config{std::move(config_)},
vfs{std::make_shared<FileSys::RealVfsFilesystem>()}, vfs{std::make_shared<FileSys::RealVfsFilesystem>()},
provider{std::make_unique<FileSys::ManualContentProvider>()} { provider{std::make_unique<FileSys::ManualContentProvider>()} {
#ifdef __unix__ #ifdef __unix__
@@ -5793,27 +5795,42 @@ void GMainWindow::closeEvent(QCloseEvent* event) {
return; return;
} }
// This stops mirroring threads before we start saving configs. // 1. STOP the emulation first
if (emu_thread != nullptr) { if (emu_thread != nullptr) {
ShutdownGame(); ShutdownGame();
} }
// Now save settings // 2. FORCE the UI to stop talking to controllers
// Do this BEFORE UnloadInputDevices
if (controller_overlay) {
// We delete it here so its destructor runs while 'system' is still healthy
delete controller_overlay;
controller_overlay = nullptr;
}
if (game_list) {
game_list->UnloadController();
}
if (controller_dialog) {
controller_dialog->UnloadController();
}
// 3. Save settings
UpdateUISettings(); UpdateUISettings();
config->SaveAllValues(); config->SaveAllValues();
game_list->SaveInterfaceLayout(); game_list->SaveInterfaceLayout();
UISettings::SaveWindowState(); UISettings::SaveWindowState();
hotkey_registry.SaveHotkeys(); hotkey_registry.SaveHotkeys();
// Unload controllers // 4. NOW it is safe to kill the hardware devices
controller_dialog->UnloadController();
game_list->UnloadController();
render_window->close(); render_window->close();
multiplayer_state->Close(); multiplayer_state->Close();
system->HIDCore().UnloadInputDevices();
system->GetRoomNetwork().Shutdown(); if (system) {
system->HIDCore().UnloadInputDevices();
system->GetRoomNetwork().Shutdown();
}
QWidget::closeEvent(event); QWidget::closeEvent(event);
} }