Skip to content

Commit

Permalink
Qt/Debugger: Snap code view to center on goto address
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Sep 9, 2024
1 parent 936c945 commit fe9d06a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/duckstation-qt/debuggerwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,15 @@ void DebuggerWindow::scrollToCodeAddress(VirtualMemoryAddress address)
{
m_code_model->ensureAddressVisible(address);

int row = m_code_model->getRowForAddress(address);
const int row = m_code_model->getRowForAddress(address);
if (row >= 0)
{
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
m_ui.codeView->scrollTo(m_code_model->index(row, 0));

const QModelIndex index = m_code_model->index(row, 0);
m_ui.codeView->scrollTo(index, QAbstractItemView::PositionAtCenter);
m_ui.codeView->selectionModel()->setCurrentIndex(index,
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
}
}

Expand Down

0 comments on commit fe9d06a

Please sign in to comment.