From ffddbcf6bb3154ceac072c0eef3921ef00221b89 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Sat, 16 Jan 2021 15:27:18 -0330 Subject: [PATCH] Fix crash when FrameBuffer message surfaces haven't been created. The next task is to move all FrameBuffer message-related functionality into its own class. --- src/emucore/FrameBuffer.cxx | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 47fd02d4b..6eb8ec6fd 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -67,10 +67,6 @@ FrameBuffer::FrameBuffer(OSystem& osystem) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FrameBuffer::~FrameBuffer() { - // Make sure to free surfaces/textures before destroying the backend itself - // Most platforms are fine with doing this in either order, but it seems - // that OpenBSD in particular crashes when attempting to destroy textures - // *after* the renderer is already destroyed cerr << "~FrameBuffer()" << endl << endl; } @@ -256,21 +252,7 @@ FBInitStatus FrameBuffer::createDisplay(const string& title, BufferType type, return FBInitStatus::FailTooLarge; #endif - // Initialize video mode handler, so it can know what video modes are - // appropriate for the requested image size - myVidModeHandler.setImageSize(size); - - // Always save, maybe only the mode of the window has changed - saveCurrentWindowPosition(); - myBufferType = type; - - // Initialize video subsystem - string pre_about = myBackend->about(); - FBInitStatus status = applyVideoMode(); - if(status != FBInitStatus::Success) - return status; - -#ifdef GUI_SUPPORT +#ifdef GUI_SUPPORT // TODO: put message stuff in its own class // Erase any messages from a previous run myMsg.enabled = false; @@ -297,6 +279,20 @@ FBInitStatus FrameBuffer::createDisplay(const string& title, BufferType type, } #endif + // Initialize video mode handler, so it can know what video modes are + // appropriate for the requested image size + myVidModeHandler.setImageSize(size); + + // Always save, maybe only the mode of the window has changed + saveCurrentWindowPosition(); + myBufferType = type; + + // Initialize video subsystem + string pre_about = myBackend->about(); + FBInitStatus status = applyVideoMode(); + if(status != FBInitStatus::Success) + return status; + // Print initial usage message, but only print it later if the status has changed if(myInitializedCount == 1) {