cleaned up debugger exiting code (fixes #516)

This commit is contained in:
thrust26 2021-04-21 14:12:13 +02:00
parent b9f4a9258f
commit c7869803b1
3 changed files with 26 additions and 24 deletions

View File

@ -153,7 +153,7 @@ bool Debugger::startWithFatalError(const string& message)
void Debugger::quit(bool exitrom) void Debugger::quit(bool exitrom)
{ {
if(exitrom) if(exitrom)
myOSystem.eventHandler().handleEvent(Event::ExitMode); myOSystem.eventHandler().handleEvent(Event::ExitGame);
else else
{ {
myOSystem.eventHandler().leaveDebugMode(); myOSystem.eventHandler().leaveDebugMode();

View File

@ -562,7 +562,6 @@ void DebuggerDialog::addRomArea()
bwidth, bheight, "Run", kDDRunCmd); bwidth, bheight, "Run", kDDRunCmd);
b->setHelpAnchor("GlobalButtons", true); b->setHelpAnchor("GlobalButtons", true);
wid2.push_back(b); wid2.push_back(b);
addCancelWidget(b);
bwidth = bheight; // 7 + 12; bwidth = bheight; // 7 + 12;
bheight = bheight * 3 + 4 * 2; bheight = bheight * 3 + 4 * 2;

View File

@ -1852,13 +1852,9 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
if (pressed && !repeated) changeStateByEvent(Event::TogglePlayBackMode); if (pressed && !repeated) changeStateByEvent(Event::TogglePlayBackMode);
return; return;
// this event is called when exiting a ROM from the debugger, so it acts like pressing ESC in emulation
case EventHandlerState::EMULATION: case EventHandlerState::EMULATION:
case EventHandlerState::DEBUGGER:
if (pressed && !repeated) if (pressed && !repeated)
{ {
if (myState == EventHandlerState::EMULATION)
{
#ifdef GUI_SUPPORT #ifdef GUI_SUPPORT
if (myOSystem.settings().getBool("confirmexit")) if (myOSystem.settings().getBool("confirmexit"))
{ {
@ -1880,9 +1876,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
else else
#endif #endif
exitEmulation(true); exitEmulation(true);
}
else
exitEmulation(true);
} }
return; return;
@ -2193,6 +2187,15 @@ bool EventHandler::changeStateByEvent(Event::Type type)
handled = false; handled = false;
break; break;
case Event::ExitMode:
// special handling for ESC key in debugger
if(myState != EventHandlerState::DEBUGGER)
{
handled = false;
break;
}
[[fallthrough]];
case Event::DebuggerMode: case Event::DebuggerMode:
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
if(myState == EventHandlerState::EMULATION || myState == EventHandlerState::PAUSE if(myState == EventHandlerState::EMULATION || myState == EventHandlerState::PAUSE