Qt/Debugger: Snap code view to center on goto address

This commit is contained in:
Stenzek 2024-09-09 20:41:10 +10:00
parent f1f0e7de14
commit 163a9d6ae4
No known key found for this signature in database
1 changed files with 6 additions and 2 deletions

View File

@ -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);
}
}