Debugger: Disable certain actions when the VM is not alive.

This commit is contained in:
Ty Lamontagne 2022-12-31 22:43:54 -05:00 committed by lightningterror
parent 51f3e1b684
commit a9a3342519
4 changed files with 24 additions and 0 deletions

View File

@ -373,6 +373,9 @@ void CpuWidget::fixBPListColumnSize()
void CpuWidget::onBPListContextMenu(QPoint pos) void CpuWidget::onBPListContextMenu(QPoint pos)
{ {
if (!m_cpu.isAlive())
return;
if (m_bplistContextMenu) if (m_bplistContextMenu)
delete m_bplistContextMenu; delete m_bplistContextMenu;
@ -951,6 +954,9 @@ std::vector<u32> startWorker(DebugInterface* cpu, int type, u32 start, u32 end,
void CpuWidget::onSearchButtonClicked() void CpuWidget::onSearchButtonClicked()
{ {
if (!m_cpu.isAlive())
return;
const int searchType = m_ui.cmbSearchType->currentIndex(); const int searchType = m_ui.cmbSearchType->currentIndex();
const bool searchHex = m_ui.chkSearchHex->isChecked(); const bool searchHex = m_ui.chkSearchHex->isChecked();

View File

@ -151,6 +151,9 @@ void DisassemblyWidget::contextJumpToCursor()
void DisassemblyWidget::contextToggleBreakpoint() void DisassemblyWidget::contextToggleBreakpoint()
{ {
if (!m_cpu->isAlive())
return;
if (CBreakPoints::IsAddressBreakPoint(m_cpu->getCpuType(), m_selectedAddressStart)) if (CBreakPoints::IsAddressBreakPoint(m_cpu->getCpuType(), m_selectedAddressStart))
{ {
Host::RunOnCPUThread([&] { CBreakPoints::RemoveBreakPoint(m_cpu->getCpuType(), m_selectedAddressStart); }); Host::RunOnCPUThread([&] { CBreakPoints::RemoveBreakPoint(m_cpu->getCpuType(), m_selectedAddressStart); });
@ -504,6 +507,9 @@ void DisassemblyWidget::mousePressEvent(QMouseEvent* event)
void DisassemblyWidget::mouseDoubleClickEvent(QMouseEvent* event) void DisassemblyWidget::mouseDoubleClickEvent(QMouseEvent* event)
{ {
if (!m_cpu->isAlive())
return;
const u32 selectedAddress = (event->y() / m_rowHeight * 4) + m_visibleStart; const u32 selectedAddress = (event->y() / m_rowHeight * 4) + m_visibleStart;
if (CBreakPoints::IsAddressBreakPoint(m_cpu->getCpuType(), selectedAddress)) if (CBreakPoints::IsAddressBreakPoint(m_cpu->getCpuType(), selectedAddress))
{ {
@ -597,6 +603,9 @@ void DisassemblyWidget::keyPressEvent(QKeyEvent* event)
void DisassemblyWidget::customMenuRequested(QPoint pos) void DisassemblyWidget::customMenuRequested(QPoint pos)
{ {
if (!m_cpu->isAlive())
return;
m_contextMenu->popup(this->mapToGlobal(pos)); m_contextMenu->popup(this->mapToGlobal(pos));
} }

View File

@ -344,12 +344,18 @@ void MemoryViewWidget::paintEvent(QPaintEvent* event)
void MemoryViewWidget::mousePressEvent(QMouseEvent* event) void MemoryViewWidget::mousePressEvent(QMouseEvent* event)
{ {
if (!m_cpu->isAlive())
return;
m_table.SelectAt(event->pos()); m_table.SelectAt(event->pos());
repaint(); repaint();
} }
void MemoryViewWidget::customMenuRequested(QPoint pos) void MemoryViewWidget::customMenuRequested(QPoint pos)
{ {
if (!m_cpu->isAlive())
return;
if (!m_contextMenu) if (!m_contextMenu)
{ {
m_contextMenu = new QMenu(this); m_contextMenu = new QMenu(this);

View File

@ -219,6 +219,9 @@ void RegisterWidget::wheelEvent(QWheelEvent* event)
void RegisterWidget::customMenuRequested(QPoint pos) void RegisterWidget::customMenuRequested(QPoint pos)
{ {
if (!m_cpu->isAlive())
return;
if (m_selectedRow > m_rowEnd) // Unsigned underflow; selectedRow will be > m_rowEnd (technically negative) if (m_selectedRow > m_rowEnd) // Unsigned underflow; selectedRow will be > m_rowEnd (technically negative)
return; return;