Skip to content

Commit

Permalink
Fix issue#1627 Breakpoints set at the new GUI not cleared correctly b…
Browse files Browse the repository at this point in the history
…y commands

For a more detailed description see:
    #1627

The problem was that when the Breakpoints window is not open (nor the
disassembly view) we didn't sync the GUI-breakpoints with the internal
openMSX breakpoints. And then they could still wrongly be saved in
imgui.ini
  • Loading branch information
m9710797 committed May 21, 2024
1 parent f1bbc93 commit ba505b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
19 changes: 9 additions & 10 deletions src/imgui/ImGuiBreakPoints.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,19 @@ void ImGuiBreakPoints::loadEnd()

void ImGuiBreakPoints::paint(MSXMotherBoard* motherBoard)
{
if (!show || !motherBoard) return;
if (!motherBoard) return;

// Sync even if not visible (e.g. for disassembly view, but also for imgui.ini)
auto& cpuInterface = motherBoard->getCPUInterface();
syncFromOpenMsx<BreakPoint> (guiBps, cpuInterface);
syncFromOpenMsx<WatchPoint> (guiWps, cpuInterface);
syncFromOpenMsx<DebugCondition>(guiConditions, cpuInterface);

if (!show) return;

ImGui::SetNextWindowSize(gl::vec2{25, 14} * ImGui::GetFontSize(), ImGuiCond_FirstUseEver);
im::Window("Breakpoints", &show, [&]{
im::TabBar("tabs", [&]{
auto& cpuInterface = motherBoard->getCPUInterface();
auto& debugger = motherBoard->getDebugger();
im::TabItem("Breakpoints", [&]{
paintTab<BreakPoint>(cpuInterface, debugger);
Expand Down Expand Up @@ -340,8 +347,6 @@ void ImGuiBreakPoints::paintTab(MSXCPUInterface& cpuInterface, Debugger& debugge
int count = 0;
int lastDrawnRow = -1; // should only be used when count=1
im::Table("items", 5, flags, {-width, 0}, [&]{
syncFromOpenMsx<Item>(items, cpuInterface);

ImGui::TableSetupScrollFreeze(0, 1); // Make top row always visible
ImGui::TableSetupColumn("Enable", ImGuiTableColumnFlags_WidthFixed | ImGuiTableColumnFlags_NoSort);
int typeFlags = isWatchPoint ? ImGuiTableColumnFlags_NoHide : ImGuiTableColumnFlags_Disabled;
Expand Down Expand Up @@ -437,12 +442,6 @@ static const std::vector<DebugCondition>& getOpenMSXItems(DebugCondition*, const
[[nodiscard]] static TclObject getCommandObj(const std::shared_ptr<WatchPoint>& wp) { return wp->getCommandObj(); }


[[nodiscard]] std::vector<ImGuiBreakPoints::GuiItem>& ImGuiBreakPoints::getBps(MSXCPUInterface& cpuInterface)
{
syncFromOpenMsx<BreakPoint>(guiBps, cpuInterface);
return guiBps;
}

template<typename Item>
void ImGuiBreakPoints::syncFromOpenMsx(std::vector<GuiItem>& items, MSXCPUInterface& cpuInterface)
{
Expand Down
2 changes: 1 addition & 1 deletion src/imgui/ImGuiBreakPoints.hh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public:

void refreshSymbols();

[[nodiscard]] std::vector<GuiItem>& getBps(MSXCPUInterface& cpuInterface);
[[nodiscard]] std::vector<GuiItem>& getBps() { return guiBps; }
void paintBpTab(MSXCPUInterface& cpuInterface, Debugger& debugger, uint16_t addr);

private:
Expand Down
2 changes: 1 addition & 1 deletion src/imgui/ImGuiDebugger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ void ImGuiDebugger::drawDisassembly(CPURegs& regs, MSXCPUInterface& cpuInterface
ImGui::TableSetupColumn("mnemonic", ImGuiTableColumnFlags_WidthStretch | ImGuiTableColumnFlags_NoHide);
ImGui::TableHeadersRow();

auto& guiBps = manager.breakPoints->getBps(cpuInterface);
auto& guiBps = manager.breakPoints->getBps();
auto textSize = ImGui::GetTextLineHeight();

std::string mnemonic;
Expand Down

0 comments on commit ba505b2

Please sign in to comment.