Skip to content

Commit

Permalink
sa2: stop debugging when the debug window is closed.
Browse files Browse the repository at this point in the history
Closes audetto#122

Signed-off-by: Andrea Odetti <[email protected]>
  • Loading branch information
audetto committed Dec 22, 2023
1 parent 2cb74b2 commit b8ad971
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
13 changes: 13 additions & 0 deletions source/frontends/sdl/imgui/sdldebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,22 @@ namespace sa2
}
}
}

if (!showDebugger)
{
// this happes when the window is closed
syncDebuggerState(frame);
}

ImGui::End();
}

void ImGuiDebugger::syncDebuggerState(SDLFrame * frame)
{
const AppMode_e mode = showDebugger ? MODE_DEBUG : MODE_RUNNING;
frame->ChangeMode(mode);
}

void ImGuiDebugger::debuggerCommand(SDLFrame * frame, const char * s)
{
for (; *s; ++s)
Expand Down
3 changes: 3 additions & 0 deletions source/frontends/sdl/imgui/sdldebugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ namespace sa2

void drawDebugger(SDLFrame* frame);
void resetDebuggerCycles();

void syncDebuggerState(SDLFrame* frame);

private:
bool mySyncCPU = true;

Expand Down
8 changes: 4 additions & 4 deletions source/frontends/sdl/imgui/sdlsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ namespace sa2
ImGui::Checkbox("Memory", &myShowMemory);
ImGui::SameLine(); HelpMarker("Show Apple memory.");

if (ImGui::Checkbox("Debugger", &myDebugger.showDebugger) && myDebugger.showDebugger)
if (ImGui::Checkbox("Debugger", &myDebugger.showDebugger))
{
frame->ChangeMode(MODE_DEBUG);
myDebugger.syncDebuggerState(frame);
}
ImGui::SameLine(); HelpMarker("Show Apple CPU.");

Expand Down Expand Up @@ -738,9 +738,9 @@ namespace sa2
{
ImGui::MenuItem("Settings", nullptr, &myShowSettings);
ImGui::MenuItem("Memory", nullptr, &myShowMemory);
if (ImGui::MenuItem("Debugger", nullptr, &myDebugger.showDebugger) && myDebugger.showDebugger)
if (ImGui::MenuItem("Debugger", nullptr, &myDebugger.showDebugger))
{
frame->ChangeMode(MODE_DEBUG);
myDebugger.syncDebuggerState(frame);
}
ImGui::EndMenu();
}
Expand Down

0 comments on commit b8ad971

Please sign in to comment.