From 6bad84a27a371248a3761e3eadf8fcca8e406caa Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 5 Jan 2024 10:42:28 +0100 Subject: [PATCH] Fixed a number of potential issues where SDL_Event unions were not properly initialized --- es-app/src/views/ViewController.cpp | 10 +++++----- es-core/src/CECInput.cpp | 2 +- es-core/src/InputManager.cpp | 4 ++-- es-core/src/InputManager.h | 1 - es-core/src/utils/PlatformUtil.cpp | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index 510d6cc71..a3f86f49f 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -162,7 +162,7 @@ void ViewController::migratedAppDataFilesDialog() mWindow->pushGui(new GuiMsgBox( HelpStyle(), message.c_str(), "QUIT", [] { - SDL_Event quit; + SDL_Event quit {}; quit.type = SDL_QUIT; SDL_PushEvent(&quit); }, @@ -201,7 +201,7 @@ void ViewController::invalidSystemsFileDialog() mWindow->pushGui(new GuiMsgBox( HelpStyle(), errorMessage.c_str(), "QUIT", [] { - SDL_Event quit; + SDL_Event quit {}; quit.type = SDL_QUIT; SDL_PushEvent(&quit); }, @@ -318,7 +318,7 @@ void ViewController::noGamesDialog() }, "QUIT", [] { - SDL_Event quit; + SDL_Event quit {}; quit.type = SDL_QUIT; SDL_PushEvent(&quit); }, @@ -1462,7 +1462,7 @@ void ViewController::rescanROMDirectory() SystemData::loadConfig(); if (SystemData::sStartupExitSignal) { - SDL_Event quit; + SDL_Event quit {}; quit.type = SDL_QUIT; SDL_PushEvent(&quit); return; @@ -1477,7 +1477,7 @@ void ViewController::rescanROMDirectory() else { preload(); if (SystemData::sStartupExitSignal) { - SDL_Event quit; + SDL_Event quit {}; quit.type = SDL_QUIT; SDL_PushEvent(&quit); return; diff --git a/es-core/src/CECInput.cpp b/es-core/src/CECInput.cpp index 03d9bc5ad..fc4fdfe8b 100644 --- a/es-core/src/CECInput.cpp +++ b/es-core/src/CECInput.cpp @@ -48,7 +48,7 @@ static void onKeyPress(void* /*cbParam*/, const CEC::cec_keypress* key) { LOG(LogDebug) << "CECInput::onKeyPress keycode: " << CECInput::getKeyCodeString(key->keycode); - SDL_Event event; + SDL_Event event {}; event.type = (key->duration > 0) ? SDL_USER_CECBUTTONUP : SDL_USER_CECBUTTONDOWN; event.user.code = key->keycode; SDL_PushEvent(&event); diff --git a/es-core/src/InputManager.cpp b/es-core/src/InputManager.cpp index 33c56e108..a830a1bf5 100644 --- a/es-core/src/InputManager.cpp +++ b/es-core/src/InputManager.cpp @@ -454,7 +454,7 @@ bool InputManager::parseEvent(const SDL_Event& event) #if defined(__ANDROID__) // Quit application if the back button is pressed. if (event.key.keysym.sym == SDLK_AC_BACK) { - SDL_Event quit; + SDL_Event quit {}; quit.type = SDL_QUIT; SDL_PushEvent(&quit); return false; @@ -490,7 +490,7 @@ bool InputManager::parseEvent(const SDL_Event& event) quitES = true; if (quitES) { - SDL_Event quit; + SDL_Event quit {}; quit.type = SDL_QUIT; SDL_PushEvent(&quit); return false; diff --git a/es-core/src/InputManager.h b/es-core/src/InputManager.h index 0814e5136..d9f3c921d 100644 --- a/es-core/src/InputManager.h +++ b/es-core/src/InputManager.h @@ -22,7 +22,6 @@ class InputConfig; class Window; -union SDL_Event; class InputManager { diff --git a/es-core/src/utils/PlatformUtil.cpp b/es-core/src/utils/PlatformUtil.cpp index 255926072..a36213539 100644 --- a/es-core/src/utils/PlatformUtil.cpp +++ b/es-core/src/utils/PlatformUtil.cpp @@ -330,7 +330,7 @@ namespace Utils { sQuitMode = mode; - SDL_Event quit; + SDL_Event quit {}; quit.type = SDL_QUIT; SDL_PushEvent(&quit); return 0;