fixed autosave

This commit is contained in:
Thomas Jentzsch 2021-05-13 23:13:06 +02:00
parent 16a3a977dd
commit cabc56b155
5 changed files with 26 additions and 9 deletions

View File

@ -26,6 +26,7 @@
#include "FSNode.hxx"
#include "Settings.hxx"
#include "DebuggerDialog.hxx"
#include "PromptWidget.hxx"
#include "DebuggerParser.hxx"
#include "StateManager.hxx"
#include "RewindManager.hxx"
@ -151,11 +152,16 @@ bool Debugger::startWithFatalError(const string& message)
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::quit(bool exitrom)
void Debugger::quit()
{
if(myOSystem.settings().getBool("dbg.autosave"))
if(myOSystem.settings().getBool("dbg.autosave")
&& myDialog->prompt().isLoaded())
myParser->run("save");
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::exit(bool exitrom)
{
if(exitrom)
myOSystem.eventHandler().handleEvent(Event::ExitGame);
else

View File

@ -102,7 +102,12 @@ class Debugger : public DialogContainer
Wrapper method for EventHandler::leaveDebugMode() for those classes
that don't have access to EventHandler.
*/
void quit(bool exitrom);
void exit(bool exitrom);
/**
Executed when debugger is quit.
*/
void quit();
bool addFunction(const string& name, const string& def,
Expression* exp, bool builtin = false);

View File

@ -153,7 +153,7 @@ string DebuggerParser::exec(const FilesystemNode& file, StringList* history)
history->push_back(command);
count++;
}
buf << "\nExecuted " << count << " commands from \""
buf << "\nExecuted " << count << " command" << (count != 1 ? "s" : "") << " from \""
<< file.getShortPath() << "\"";
return buf.str();
@ -1332,7 +1332,7 @@ void DebuggerParser::executeExec()
// "exitRom"
void DebuggerParser::executeExitRom()
{
debugger.quit(true);
debugger.exit(true);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1690,7 +1690,7 @@ void DebuggerParser::executeLogBreaks()
bool enable = !debugger.mySystem.m6502().getLogBreaks();
debugger.mySystem.m6502().setLogBreaks(enable);
settings.setValue("dbg.logBreaks", enable);
settings.setValue("dbg.logbreaks", enable);
commandResult << "logBreaks " << (enable ? "enabled" : "disabled");
}
@ -1814,7 +1814,7 @@ void DebuggerParser::executeRow()
void DebuggerParser::executeRun()
{
debugger.saveOldState();
debugger.quit(false);
debugger.exit(false);
commandResult << "_EXIT_DEBUGGER"; // See PromptWidget for more info
}

View File

@ -46,13 +46,15 @@ class PromptWidget : public Widget, public CommandSender
void printPrompt();
string saveBuffer(const FilesystemNode& file);
// Clear screen
// Clear screen
void clearScreen();
// Erase all history
void clearHistory();
void addToHistory(const char *str);
bool isLoaded() const { return !_firstTime; }
protected:
ATTRIBUTE_FMT_PRINTF int printf(const char* format, ...);
ATTRIBUTE_FMT_PRINTF int vprintf(const char* format, va_list argptr);

View File

@ -54,6 +54,7 @@
#endif
#ifdef DEBUGGER_SUPPORT
#include "Debugger.hxx"
#include "DebuggerParser.hxx"
#endif
#ifdef GUI_SUPPORT
#include "Menu.hxx"
@ -2996,12 +2997,15 @@ void EventHandler::exitEmulation(bool checkLauncher)
const bool activeTM = myOSystem.settings().getBool(
myOSystem.settings().getBool("dev.settings") ? "dev.timemachine" : "plr.timemachine");
if (saveOnExit == "all" && activeTM)
handleEvent(Event::SaveAllStates);
else if (saveOnExit == "current")
handleEvent(Event::SaveState);
#if DEBUGGER_SUPPORT
myOSystem.debugger().quit();
#endif
if (checkLauncher)
{
// Go back to the launcher, or immediately quit