From fdf63a9ad05bc580d1037585de55491972b7f210 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Wed, 18 May 2022 22:57:03 +0200 Subject: [PATCH] Fixed an issue where the 'quit' custom event would not trigger on application shutdown. --- es-app/src/guis/GuiMenu.cpp | 6 ------ es-core/src/Window.h | 1 - es-core/src/resources/ResourceManager.cpp | 2 -- es-core/src/utils/PlatformUtil.cpp | 7 +++++++ 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index ac54aada6..fa6ddbb22 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -1296,7 +1296,6 @@ void GuiMenu::openQuitMenu() mWindow->pushGui(new GuiMsgBox( this->getHelpStyle(), "REALLY QUIT?", "YES", [this] { - Scripting::fireEvent("quit"); close(true); Utils::Platform::quitES(); }, @@ -1314,7 +1313,6 @@ void GuiMenu::openQuitMenu() window->pushGui(new GuiMsgBox( this->getHelpStyle(), "REALLY QUIT?", "YES", [this] { - Scripting::fireEvent("quit"); close(true); Utils::Platform::quitES(); }, @@ -1331,8 +1329,6 @@ void GuiMenu::openQuitMenu() window->pushGui(new GuiMsgBox( this->getHelpStyle(), "REALLY REBOOT?", "YES", [] { - Scripting::fireEvent("quit", "reboot"); - Scripting::fireEvent("reboot"); if (Utils::Platform::quitES(Utils::Platform::QuitMode::REBOOT) != 0) { LOG(LogWarning) << "Reboot terminated with non-zero result!"; } @@ -1350,8 +1346,6 @@ void GuiMenu::openQuitMenu() window->pushGui(new GuiMsgBox( this->getHelpStyle(), "REALLY POWER OFF?", "YES", [] { - Scripting::fireEvent("quit", "poweroff"); - Scripting::fireEvent("poweroff"); if (Utils::Platform::quitES(Utils::Platform::QuitMode::POWEROFF) != 0) { LOG(LogWarning) << "Power off terminated with non-zero result!"; } diff --git a/es-core/src/Window.h b/es-core/src/Window.h index a5db9e336..b9b8fc72d 100644 --- a/es-core/src/Window.h +++ b/es-core/src/Window.h @@ -12,7 +12,6 @@ #include "HelpPrompt.h" #include "InputConfig.h" -#include "Scripting.h" #include "Settings.h" #include "resources/TextureResource.h" diff --git a/es-core/src/resources/ResourceManager.cpp b/es-core/src/resources/ResourceManager.cpp index 677f0ab5b..148cf5a94 100644 --- a/es-core/src/resources/ResourceManager.cpp +++ b/es-core/src/resources/ResourceManager.cpp @@ -10,7 +10,6 @@ #include "ResourceManager.h" #include "Log.h" -#include "Scripting.h" #include "utils/FileSystemUtil.h" #include "utils/PlatformUtil.h" #include "utils/StringUtil.h" @@ -77,7 +76,6 @@ std::string ResourceManager::getResourcePath(const std::string& path, bool termi #endif LOG(LogError) << testExePath; LOG(LogError) << "Has EmulationStation been properly installed?"; - Scripting::fireEvent("quit"); Utils::Platform::emergencyShutdown(); } else { diff --git a/es-core/src/utils/PlatformUtil.cpp b/es-core/src/utils/PlatformUtil.cpp index a702c464c..5912f9f50 100644 --- a/es-core/src/utils/PlatformUtil.cpp +++ b/es-core/src/utils/PlatformUtil.cpp @@ -9,6 +9,7 @@ #include "utils/PlatformUtil.h" #include "Log.h" +#include "Scripting.h" #include "Window.h" #if defined(_WIN64) #include "utils/StringUtil.h" @@ -286,15 +287,20 @@ namespace Utils switch (sQuitMode) { case QuitMode::REBOOT: { LOG(LogInfo) << "Rebooting system"; + Scripting::fireEvent("quit"); + Scripting::fireEvent("reboot"); runRebootCommand(); break; } case QuitMode::POWEROFF: { LOG(LogInfo) << "Powering off system"; + Scripting::fireEvent("quit"); + Scripting::fireEvent("poweroff"); runPoweroffCommand(); break; } default: { + Scripting::fireEvent("quit"); break; } } @@ -303,6 +309,7 @@ namespace Utils void emergencyShutdown() { LOG(LogError) << "Critical - Performing emergency shutdown..."; + Scripting::fireEvent("quit"); Window::getInstance()->deinit(); Log::flush();