From fb4332a0c7786d61e0157b92f51fc4054d8b0e16 Mon Sep 17 00:00:00 2001 From: stephena Date: Thu, 20 Nov 2014 14:20:03 +0000 Subject: [PATCH] Catch very early fatal warning from SDL when it can't even initialize itself. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3094 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/common/FrameBufferSDL2.cxx | 2 +- src/emucore/OSystem.cxx | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/common/FrameBufferSDL2.cxx b/src/common/FrameBufferSDL2.cxx index 8ab38cbda..74d017c75 100644 --- a/src/common/FrameBufferSDL2.cxx +++ b/src/common/FrameBufferSDL2.cxx @@ -47,7 +47,7 @@ FrameBufferSDL2::FrameBufferSDL2(OSystem& osystem) ostringstream buf; buf << "ERROR: Couldn't initialize SDL: " << SDL_GetError() << endl; myOSystem.logMessage(buf.str(), 0); - return; + throw "FATAL ERROR"; } myOSystem.logMessage("FrameBufferSDL2::FrameBufferSDL2 SDL_Init()", 2); diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 6d16c7c1b..921340637 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -120,7 +120,8 @@ bool OSystem::create() // Get relevant information about the video hardware // This must be done before any graphics context is created, since // it may be needed to initialize the size of graphical objects - myFrameBuffer = MediaFactory::createVideo(*this); + try { myFrameBuffer = MediaFactory::createVideo(*this); } + catch(...) { return false; } if(!myFrameBuffer->initialize()) return false; @@ -174,9 +175,11 @@ void OSystem::loadConfig() void OSystem::saveConfig() { // Ask all subsystems to save their settings - myFrameBuffer->tiaSurface().ntsc().saveConfig(*mySettings); + if(myFrameBuffer) + myFrameBuffer->tiaSurface().ntsc().saveConfig(*mySettings); - mySettings->saveConfig(); + if(mySettings) + mySettings->saveConfig(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -