From 163a9d6ae442dbc4690b254353fb5f66571865b3 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Mon, 9 Sep 2024 20:41:10 +1000 Subject: [PATCH] Qt/Debugger: Snap code view to center on goto address --- src/duckstation-qt/debuggerwindow.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/duckstation-qt/debuggerwindow.cpp b/src/duckstation-qt/debuggerwindow.cpp index fa9379a50..1639e87ab 100644 --- a/src/duckstation-qt/debuggerwindow.cpp +++ b/src/duckstation-qt/debuggerwindow.cpp @@ -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); } }