Fixed a tiny memory leak.

Also fixed a Clang static analyzer error for SystemData.
This commit is contained in:
Leon Styhre 2020-10-17 14:32:08 +02:00
parent 930bdce576
commit 0beb40d9c9
4 changed files with 16 additions and 16 deletions

View file

@ -513,7 +513,7 @@ SystemData* SystemData::getRandomSystem(const SystemData* currentSystem)
if (total < 2) if (total < 2)
return nullptr; return nullptr;
SystemData* randomSystem; SystemData* randomSystem = nullptr;
do { do {
// Get a random number in range. // Get a random number in range.

View file

@ -511,18 +511,18 @@ int main(int argc, char* argv[])
window.pushGui(new GuiMsgBox(&window, helpStyle, window.pushGui(new GuiMsgBox(&window, helpStyle,
errorMsg.c_str(), errorMsg.c_str(),
"QUIT", [] { "QUIT", [] {
SDL_Event* quit = new SDL_Event(); SDL_Event quit;
quit->type = SDL_QUIT; quit.type = SDL_QUIT;
SDL_PushEvent(quit); SDL_PushEvent(&quit);
}, "", nullptr, "", nullptr, true)); }, "", nullptr, "", nullptr, true));
} }
else if (returnCodeValue == NO_ROMS) { else if (returnCodeValue == NO_ROMS) {
auto updateVal = [](const std::string& newROMDirectory) { auto updateVal = [](const std::string& newROMDirectory) {
Settings::getInstance()->setString("ROMDirectory", newROMDirectory); Settings::getInstance()->setString("ROMDirectory", newROMDirectory);
Settings::getInstance()->saveFile(); Settings::getInstance()->saveFile();
SDL_Event* quit = new SDL_Event(); SDL_Event quit;
quit->type = SDL_QUIT; quit.type = SDL_QUIT;
SDL_PushEvent(quit); SDL_PushEvent(&quit);
}; };
window.pushGui(new GuiMsgBox(&window, helpStyle, errorMsg.c_str(), window.pushGui(new GuiMsgBox(&window, helpStyle, errorMsg.c_str(),
@ -553,9 +553,9 @@ int main(int argc, char* argv[])
true)); true));
}, },
"QUIT", [] { "QUIT", [] {
SDL_Event* quit = new SDL_Event(); SDL_Event quit;
quit->type = SDL_QUIT; quit.type = SDL_QUIT;
SDL_PushEvent(quit); SDL_PushEvent(&quit);
}, "", nullptr, true)); }, "", nullptr, true));
} }
} }

View file

@ -289,9 +289,9 @@ bool InputManager::parseEvent(const SDL_Event& ev, Window* window)
return false; return false;
if (ev.key.keysym.sym == SDLK_F4) { if (ev.key.keysym.sym == SDLK_F4) {
SDL_Event* quit = new SDL_Event(); SDL_Event quit;
quit->type = SDL_QUIT; quit.type = SDL_QUIT;
SDL_PushEvent(quit); SDL_PushEvent(&quit);
return false; return false;
} }

View file

@ -224,9 +224,9 @@ int quitES(QuitMode mode)
{ {
quitMode = mode; quitMode = mode;
SDL_Event *quit = new SDL_Event(); SDL_Event quit;
quit->type = SDL_QUIT; quit.type = SDL_QUIT;
SDL_PushEvent(quit); SDL_PushEvent(&quit);
return 0; return 0;
} }