Debugger: Hide breakpoint and callstack list if unused (#12266)

This commit is contained in:
Elad Ashkenazi 2022-06-22 00:42:42 +03:00 committed by GitHub
parent ccb2724fc4
commit 69ceebeb05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View file

@ -26,6 +26,9 @@ breakpoint_list::breakpoint_list(QWidget* parent, breakpoint_handler* handler) :
m_delete_action->setShortcutContext(Qt::WidgetShortcut); m_delete_action->setShortcutContext(Qt::WidgetShortcut);
connect(m_delete_action, &QAction::triggered, this, &breakpoint_list::OnBreakpointListDelete); connect(m_delete_action, &QAction::triggered, this, &breakpoint_list::OnBreakpointListDelete);
addAction(m_delete_action); addAction(m_delete_action);
// Hide until used in order to allow as much space for registers panel as possible
hide();
} }
/** /**
@ -46,6 +49,8 @@ void breakpoint_list::ClearBreakpoints()
m_ppu_breakpoint_handler->RemoveBreakpoint(loc); m_ppu_breakpoint_handler->RemoveBreakpoint(loc);
delete currentItem; delete currentItem;
} }
hide();
} }
void breakpoint_list::RemoveBreakpoint(u32 addr) void breakpoint_list::RemoveBreakpoint(u32 addr)
@ -64,6 +69,11 @@ void breakpoint_list::RemoveBreakpoint(u32 addr)
} }
Q_EMIT RequestShowAddress(addr); Q_EMIT RequestShowAddress(addr);
if (!count())
{
hide();
}
} }
bool breakpoint_list::AddBreakpoint(u32 pc) bool breakpoint_list::AddBreakpoint(u32 pc)
@ -86,6 +96,8 @@ bool breakpoint_list::AddBreakpoint(u32 pc)
Q_EMIT RequestShowAddress(pc); Q_EMIT RequestShowAddress(pc);
show();
return true; return true;
} }

View file

@ -12,6 +12,9 @@ call_stack_list::call_stack_list(QWidget* parent) : QListWidget(parent)
// connects // connects
connect(this, &QListWidget::itemDoubleClicked, this, &call_stack_list::OnCallStackListDoubleClicked); connect(this, &QListWidget::itemDoubleClicked, this, &call_stack_list::OnCallStackListDoubleClicked);
// Hide until used in order to allow as much space for registers panel as possible
hide();
} }
void call_stack_list::HandleUpdate(const std::vector<std::pair<u32, u32>>& call_stack) void call_stack_list::HandleUpdate(const std::vector<std::pair<u32, u32>>& call_stack)
@ -25,6 +28,8 @@ void call_stack_list::HandleUpdate(const std::vector<std::pair<u32, u32>>& call_
call_stack_item->setData(Qt::UserRole, { addr.first }); call_stack_item->setData(Qt::UserRole, { addr.first });
addItem(call_stack_item); addItem(call_stack_item);
} }
setVisible(!call_stack.empty());
} }
void call_stack_list::OnCallStackListDoubleClicked() void call_stack_list::OnCallStackListDoubleClicked()

View file

@ -860,6 +860,7 @@ void debugger_frame::UpdateUnitList()
if (emu_state == system_state::stopped) if (emu_state == system_state::stopped)
{ {
ClearBreakpoints(); ClearBreakpoints();
ClearCallStack();
} }
OnSelectUnit(); OnSelectUnit();
@ -982,14 +983,18 @@ void debugger_frame::WritePanels()
} }
int loc = m_misc_state->verticalScrollBar()->value(); int loc = m_misc_state->verticalScrollBar()->value();
int hloc = m_misc_state->horizontalScrollBar()->value();
m_misc_state->clear(); m_misc_state->clear();
m_misc_state->setText(qstr(cpu->dump_misc())); m_misc_state->setText(qstr(cpu->dump_misc()));
m_misc_state->verticalScrollBar()->setValue(loc); m_misc_state->verticalScrollBar()->setValue(loc);
m_misc_state->horizontalScrollBar()->setValue(hloc);
loc = m_regs->verticalScrollBar()->value(); loc = m_regs->verticalScrollBar()->value();
hloc = m_regs->horizontalScrollBar()->value();
m_regs->clear(); m_regs->clear();
m_regs->setText(qstr(cpu->dump_regs())); m_regs->setText(qstr(cpu->dump_regs()));
m_regs->verticalScrollBar()->setValue(loc); m_regs->verticalScrollBar()->setValue(loc);
m_regs->horizontalScrollBar()->setValue(hloc);
Q_EMIT CallStackUpdateRequested(cpu->dump_callstack_list()); Q_EMIT CallStackUpdateRequested(cpu->dump_callstack_list());
} }