Fixed some potential segfaults on emergency shutdown.

This commit is contained in:
Leon Styhre 2022-01-10 17:41:08 +01:00
parent f80658696c
commit c3dbdd431c
2 changed files with 12 additions and 3 deletions

View file

@ -227,6 +227,10 @@ void ViewController::invalidAlternativeEmulatorDialog()
void ViewController::goToStart(bool playTransition) void ViewController::goToStart(bool playTransition)
{ {
// Needed to avoid segfaults during emergency shutdown.
if (Renderer::getSDLWindow() == nullptr)
return;
#if defined(__APPLE__) #if defined(__APPLE__)
// The startup animations are very choppy on macOS as of moving to SDL 2.0.18 so the // The startup animations are very choppy on macOS as of moving to SDL 2.0.18 so the
// best user experience is to simply disable them on this OS. // best user experience is to simply disable them on this OS.
@ -310,6 +314,9 @@ void ViewController::cancelViewTransitions()
void ViewController::stopScrolling() void ViewController::stopScrolling()
{ {
if (Renderer::getSDLWindow() == nullptr)
return;
mSystemListView->stopScrolling(); mSystemListView->stopScrolling();
mCurrentView->stopListScrolling(); mCurrentView->stopListScrolling();
@ -1031,6 +1038,9 @@ void ViewController::reloadGameListView(IGameListView* view, bool reloadTheme)
void ViewController::reloadAll() void ViewController::reloadAll()
{ {
if (Renderer::getSDLWindow() == nullptr)
return;
cancelViewTransitions(); cancelViewTransitions();
// Clear all GameListViews. // Clear all GameListViews.

View file

@ -11,7 +11,7 @@
#include "Log.h" #include "Log.h"
#include "MameNames.h" #include "MameNames.h"
#include "Settings.h" #include "Settings.h"
#include "renderers/Renderer.h" #include "Window.h"
#include "utils/StringUtil.h" #include "utils/StringUtil.h"
#include <SDL2/SDL_events.h> #include <SDL2/SDL_events.h>
@ -270,8 +270,7 @@ void emergencyShutdown()
{ {
LOG(LogError) << "Critical - Performing emergency shutdown..."; LOG(LogError) << "Critical - Performing emergency shutdown...";
// Most of the SDL deinitialization is done in Renderer. Window::getInstance()->deinit();
Renderer::deinit();
Log::flush(); Log::flush();
exit(EXIT_FAILURE); exit(EXIT_FAILURE);