From 32f8c8ba2fb1a51aeca799b6423dc4d1b38087a3 Mon Sep 17 00:00:00 2001 From: stephena Date: Sun, 31 Dec 2006 17:21:17 +0000 Subject: [PATCH] Fixed segfault when a ROM had per-frame cheats enabled. Apparently the cheats were being evaluated even after the console was deleted. Also moved saving of cheats out of the Console d'tor. I never liked that required functionality was in a d'tor; it felt sort of hacky. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1257 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/cheat/CheatManager.cxx | 3 ++- stella/src/emucore/Console.cxx | 6 +----- stella/src/emucore/OSystem.cxx | 20 +++++++++----------- stella/src/gui/Launcher.cxx | 16 ++++------------ stella/src/gui/Launcher.hxx | 10 ++-------- stella/src/gui/LauncherDialog.cxx | 18 +++++++++--------- 6 files changed, 27 insertions(+), 46 deletions(-) diff --git a/stella/src/cheat/CheatManager.cxx b/stella/src/cheat/CheatManager.cxx index c8d2d507c..6f1a1cee8 100644 --- a/stella/src/cheat/CheatManager.cxx +++ b/stella/src/cheat/CheatManager.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: CheatManager.cxx,v 1.11 2006-12-08 16:48:55 stephena Exp $ +// $Id: CheatManager.cxx,v 1.12 2006-12-31 17:21:17 stephena Exp $ //============================================================================ #include @@ -339,6 +339,7 @@ void CheatManager::saveCheats(const string& md5sum) // Update the dirty flag myListIsDirty = myListIsDirty || changed; + clear(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/stella/src/emucore/Console.cxx b/stella/src/emucore/Console.cxx index f6b1b8e86..590a2082a 100644 --- a/stella/src/emucore/Console.cxx +++ b/stella/src/emucore/Console.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Console.cxx,v 1.117 2006-12-31 02:16:37 stephena Exp $ +// $Id: Console.cxx,v 1.118 2006-12-31 17:21:17 stephena Exp $ //============================================================================ #include @@ -229,10 +229,6 @@ Console::Console(OSystem* osystem, Cartridge* cart, const Properties& props) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Console::~Console() { -#ifdef CHEATCODE_SUPPORT - myOSystem->cheat().saveCheats(myProperties.get(Cartridge_MD5)); -#endif - delete mySystem; delete mySwitches; delete myControllers[0]; diff --git a/stella/src/emucore/OSystem.cxx b/stella/src/emucore/OSystem.cxx index 3b6ec48aa..7d9440551 100644 --- a/stella/src/emucore/OSystem.cxx +++ b/stella/src/emucore/OSystem.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: OSystem.cxx,v 1.87 2006-12-30 22:26:28 stephena Exp $ +// $Id: OSystem.cxx,v 1.88 2006-12-31 17:21:17 stephena Exp $ //============================================================================ #include @@ -397,9 +397,12 @@ bool OSystem::createConsole(const string& romfile) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void OSystem::deleteConsole() { - mySound->close(); if(myConsole) { + mySound->close(); + #ifdef CHEATCODE_SUPPORT + myCheatManager->saveCheats(myConsole->properties().get(Cartridge_MD5)); + #endif if(mySettings->getBool("showinfo")) { double executionTime = (double) myTimingInfo.totalTime / 1000000.0; @@ -417,18 +420,14 @@ void OSystem::deleteConsole() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void OSystem::createLauncher() { - resetLoopTiming(); - - setFramerate(60); myEventHandler->reset(EventHandler::S_LAUNCHER); createFrameBuffer(false); - - // And start the base dialog - myLauncher->initialize(); myLauncher->reStack(); - - myEventHandler->refreshDisplay(); myFrameBuffer->setCursorState(); + myEventHandler->refreshDisplay(); + + setFramerate(60); + resetLoopTiming(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -692,7 +691,6 @@ void OSystem::mainLoop() myEventHandler->poll(myTimingInfo.start); if(myQuitLoop) break; // Exit if the user wants to quit myFrameBuffer->update(); - myTimingInfo.current = getTicks(); myTimingInfo.virt += myTimePerFrame; diff --git a/stella/src/gui/Launcher.cxx b/stella/src/gui/Launcher.cxx index 8aab95d58..f72bf4ec3 100644 --- a/stella/src/gui/Launcher.cxx +++ b/stella/src/gui/Launcher.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Launcher.cxx,v 1.8 2006-12-08 16:49:35 stephena Exp $ +// $Id: Launcher.cxx,v 1.9 2006-12-31 17:21:17 stephena Exp $ //============================================================================ #include "Version.hxx" @@ -25,8 +25,10 @@ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Launcher::Launcher(OSystem* osystem) - : DialogContainer(osystem) + : DialogContainer(osystem) { + myBaseDialog = new LauncherDialog(myOSystem, this, + 0, 0, kLauncherWidth, kLauncherHeight); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -34,16 +36,6 @@ Launcher::~Launcher() { } -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Launcher::initialize() -{ - // We only create one instance of this dialog, since each time we do so, - // the ROM listing is read from disk. This can be very expensive. - if(myBaseDialog == NULL) - myBaseDialog = new LauncherDialog(myOSystem, this, - 0, 0, kLauncherWidth, kLauncherHeight); -} - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Launcher::initializeVideo() { diff --git a/stella/src/gui/Launcher.hxx b/stella/src/gui/Launcher.hxx index b987e17a6..777bcb6de 100644 --- a/stella/src/gui/Launcher.hxx +++ b/stella/src/gui/Launcher.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Launcher.hxx,v 1.6 2006-12-08 16:49:35 stephena Exp $ +// $Id: Launcher.hxx,v 1.7 2006-12-31 17:21:17 stephena Exp $ //============================================================================ #ifndef LAUNCHER_HXX @@ -34,7 +34,7 @@ enum { The base dialog for the ROM launcher in Stella. @author Stephen Anthony - @version $Id: Launcher.hxx,v 1.6 2006-12-08 16:49:35 stephena Exp $ + @version $Id: Launcher.hxx,v 1.7 2006-12-31 17:21:17 stephena Exp $ */ class Launcher : public DialogContainer { @@ -49,12 +49,6 @@ class Launcher : public DialogContainer */ virtual ~Launcher(); - public: - /** - Updates the basedialog to be of the type defined for this derived class. - */ - void initialize(); - /** Initialize the video subsystem wrt this class. */ diff --git a/stella/src/gui/LauncherDialog.cxx b/stella/src/gui/LauncherDialog.cxx index 8d99b46c3..ebccbec70 100644 --- a/stella/src/gui/LauncherDialog.cxx +++ b/stella/src/gui/LauncherDialog.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: LauncherDialog.cxx,v 1.63 2006-12-30 22:26:29 stephena Exp $ +// $Id: LauncherDialog.cxx,v 1.64 2006-12-31 17:21:17 stephena Exp $ // // Based on code from ScummVM - Scumm Interpreter // Copyright (C) 2002-2004 The ScummVM project @@ -139,13 +139,6 @@ LauncherDialog::LauncherDialog(OSystem* osystem, DialogContainer* parent, myGameList = new GameList(); addToFocusList(wid); - - // (De)activate browse mode - myBrowseModeFlag = instance()->settings().getBool("rombrowse"); - myPrevDirButton->setEnabled(myBrowseModeFlag); - myNoteLabel->setLabel(myBrowseModeFlag ? "Dir:" : "Note:"); - - myCurrentNode = instance()->settings().getString("romdir"); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -161,8 +154,15 @@ void LauncherDialog::loadConfig() // Assume that if the list is empty, this is the first time that loadConfig() // has been called (and we should reload the list). if(myList->getList().isEmpty()) - updateListing(); + { + // (De)activate browse mode + myBrowseModeFlag = instance()->settings().getBool("rombrowse"); + myPrevDirButton->setEnabled(myBrowseModeFlag); + myNoteLabel->setLabel(myBrowseModeFlag ? "Dir:" : "Note:"); + myCurrentNode = instance()->settings().getString("romdir"); + updateListing(); + } Dialog::setFocus(getFocusList()[mySelectedItem]); }