Fixed an issue where the 'quit' custom event would not trigger on application shutdown.

This commit is contained in:
Leon Styhre 2022-05-18 22:57:03 +02:00
parent 5b63ecb828
commit fdf63a9ad0
4 changed files with 7 additions and 9 deletions

View file

@ -1296,7 +1296,6 @@ void GuiMenu::openQuitMenu()
mWindow->pushGui(new GuiMsgBox( mWindow->pushGui(new GuiMsgBox(
this->getHelpStyle(), "REALLY QUIT?", "YES", this->getHelpStyle(), "REALLY QUIT?", "YES",
[this] { [this] {
Scripting::fireEvent("quit");
close(true); close(true);
Utils::Platform::quitES(); Utils::Platform::quitES();
}, },
@ -1314,7 +1313,6 @@ void GuiMenu::openQuitMenu()
window->pushGui(new GuiMsgBox( window->pushGui(new GuiMsgBox(
this->getHelpStyle(), "REALLY QUIT?", "YES", this->getHelpStyle(), "REALLY QUIT?", "YES",
[this] { [this] {
Scripting::fireEvent("quit");
close(true); close(true);
Utils::Platform::quitES(); Utils::Platform::quitES();
}, },
@ -1331,8 +1329,6 @@ void GuiMenu::openQuitMenu()
window->pushGui(new GuiMsgBox( window->pushGui(new GuiMsgBox(
this->getHelpStyle(), "REALLY REBOOT?", "YES", this->getHelpStyle(), "REALLY REBOOT?", "YES",
[] { [] {
Scripting::fireEvent("quit", "reboot");
Scripting::fireEvent("reboot");
if (Utils::Platform::quitES(Utils::Platform::QuitMode::REBOOT) != 0) { if (Utils::Platform::quitES(Utils::Platform::QuitMode::REBOOT) != 0) {
LOG(LogWarning) << "Reboot terminated with non-zero result!"; LOG(LogWarning) << "Reboot terminated with non-zero result!";
} }
@ -1350,8 +1346,6 @@ void GuiMenu::openQuitMenu()
window->pushGui(new GuiMsgBox( window->pushGui(new GuiMsgBox(
this->getHelpStyle(), "REALLY POWER OFF?", "YES", this->getHelpStyle(), "REALLY POWER OFF?", "YES",
[] { [] {
Scripting::fireEvent("quit", "poweroff");
Scripting::fireEvent("poweroff");
if (Utils::Platform::quitES(Utils::Platform::QuitMode::POWEROFF) != 0) { if (Utils::Platform::quitES(Utils::Platform::QuitMode::POWEROFF) != 0) {
LOG(LogWarning) << "Power off terminated with non-zero result!"; LOG(LogWarning) << "Power off terminated with non-zero result!";
} }

View file

@ -12,7 +12,6 @@
#include "HelpPrompt.h" #include "HelpPrompt.h"
#include "InputConfig.h" #include "InputConfig.h"
#include "Scripting.h"
#include "Settings.h" #include "Settings.h"
#include "resources/TextureResource.h" #include "resources/TextureResource.h"

View file

@ -10,7 +10,6 @@
#include "ResourceManager.h" #include "ResourceManager.h"
#include "Log.h" #include "Log.h"
#include "Scripting.h"
#include "utils/FileSystemUtil.h" #include "utils/FileSystemUtil.h"
#include "utils/PlatformUtil.h" #include "utils/PlatformUtil.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
@ -77,7 +76,6 @@ std::string ResourceManager::getResourcePath(const std::string& path, bool termi
#endif #endif
LOG(LogError) << testExePath; LOG(LogError) << testExePath;
LOG(LogError) << "Has EmulationStation been properly installed?"; LOG(LogError) << "Has EmulationStation been properly installed?";
Scripting::fireEvent("quit");
Utils::Platform::emergencyShutdown(); Utils::Platform::emergencyShutdown();
} }
else { else {

View file

@ -9,6 +9,7 @@
#include "utils/PlatformUtil.h" #include "utils/PlatformUtil.h"
#include "Log.h" #include "Log.h"
#include "Scripting.h"
#include "Window.h" #include "Window.h"
#if defined(_WIN64) #if defined(_WIN64)
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
@ -286,15 +287,20 @@ namespace Utils
switch (sQuitMode) { switch (sQuitMode) {
case QuitMode::REBOOT: { case QuitMode::REBOOT: {
LOG(LogInfo) << "Rebooting system"; LOG(LogInfo) << "Rebooting system";
Scripting::fireEvent("quit");
Scripting::fireEvent("reboot");
runRebootCommand(); runRebootCommand();
break; break;
} }
case QuitMode::POWEROFF: { case QuitMode::POWEROFF: {
LOG(LogInfo) << "Powering off system"; LOG(LogInfo) << "Powering off system";
Scripting::fireEvent("quit");
Scripting::fireEvent("poweroff");
runPoweroffCommand(); runPoweroffCommand();
break; break;
} }
default: { default: {
Scripting::fireEvent("quit");
break; break;
} }
} }
@ -303,6 +309,7 @@ namespace Utils
void emergencyShutdown() void emergencyShutdown()
{ {
LOG(LogError) << "Critical - Performing emergency shutdown..."; LOG(LogError) << "Critical - Performing emergency shutdown...";
Scripting::fireEvent("quit");
Window::getInstance()->deinit(); Window::getInstance()->deinit();
Log::flush(); Log::flush();