Don't always scroll to PC when updating debug window assembly view.

Change ConsoleDebugger::updateWindowData and updateAllDebuggerWindows to support
two different types of updates: UPDATE_ALL and UPDATE_NO_SCROLL. The new
"no scroll" type lets callers request the assembly view be updated without
scrolling the view to the PC line.

Change the hex editor and trace logger calls to updateAllDebuggerWindows to use
the no scroll update. The user may use these functions with the current
disassembly position in mind and not want to lose it.
This commit is contained in:
Fritz Mahnke 2023-04-17 11:25:46 -07:00
parent 46054d190c
commit 39bb749f5d
4 changed files with 37 additions and 28 deletions

View File

@ -172,7 +172,7 @@ ConsoleDebugger::ConsoleDebugger(QWidget *parent)
loadDisplayViews();
windowUpdateReq = true;
windowUpdateReq = QAsmView::UPDATE_ALL;
dbgWin = this;
@ -373,7 +373,7 @@ void ConsoleDebugger::ld65ImportDebug(void)
debugSymbolTable.ld65LoadDebugFile( filename.toStdString().c_str() );
queueUpdate();
queueUpdate(QAsmView::UPDATE_ALL);
return;
}
@ -2985,7 +2985,7 @@ void ConsoleDebugger::debugStepBackCB(void)
{
FCEU_WRAPPER_LOCK();
FCEUD_TraceLoggerBackUpInstruction();
updateWindowData();
updateWindowData(QAsmView::UPDATE_ALL);
hexEditorUpdateMemoryValues(true);
hexEditorRequestUpdateAll();
lastBpIdx = BREAK_TYPE_STEP;
@ -3180,8 +3180,7 @@ void ConsoleDebugger::seekPCCB (void)
setRegsFromEntry();
//updateAllDebugWindows();
}
windowUpdateReq = true;
//asmView->scrollToPC();
windowUpdateReq = QAsmView::UPDATE_ALL;
}
//----------------------------------------------------------------------------
void ConsoleDebugger::openChangePcDialog(void)
@ -3235,7 +3234,7 @@ void ConsoleDebugger::openChangePcDialog(void)
{
X.PC = sbox->value();
windowUpdateReq = true;
windowUpdateReq = QAsmView::UPDATE_ALL;
}
}
//----------------------------------------------------------------------------
@ -4229,20 +4228,25 @@ void ConsoleDebugger::updateRegisterView(void)
ppuScrollY->setText( tr(stmp) );
}
//----------------------------------------------------------------------------
void ConsoleDebugger::updateWindowData(void)
void ConsoleDebugger::updateWindowData(enum QAsmView::UpdateType type)
{
asmView->updateAssemblyView();
asmView->scrollToPC();
if (type == QAsmView::UPDATE_ALL)
{
asmView->updateAssemblyView();
asmView->scrollToPC();
updateRegisterView();
} else if (type == QAsmView::UPDATE_NO_SCROLL)
{
asmView->updateAssemblyView();
updateRegisterView();
}
updateRegisterView();
windowUpdateReq = false;
windowUpdateReq = QAsmView::UPDATE_NONE;
}
//----------------------------------------------------------------------------
void ConsoleDebugger::queueUpdate(void)
void ConsoleDebugger::queueUpdate(enum QAsmView::UpdateType type)
{
windowUpdateReq = true;
windowUpdateReq = type;
}
//----------------------------------------------------------------------------
void ConsoleDebugger::updatePeriodic(void)
@ -4260,10 +4264,10 @@ void ConsoleDebugger::updatePeriodic(void)
bpNotifyReq = false;
}
if ( windowUpdateReq )
if ( windowUpdateReq != QAsmView::UPDATE_NONE )
{
FCEU_WRAPPER_LOCK();
updateWindowData();
updateWindowData(windowUpdateReq);
FCEU_WRAPPER_UNLOCK();
}
asmView->update();
@ -4433,7 +4437,7 @@ void ConsoleDebugger::breakPointNotify( int bpNum )
}
}
windowUpdateReq = true;
windowUpdateReq = QAsmView::UPDATE_ALL;
}
//----------------------------------------------------------------------------
void ConsoleDebugger::hbarChanged(int value)
@ -4556,11 +4560,11 @@ bool debuggerWaitingAtBreakpoint(void)
return waitingAtBp;
}
//----------------------------------------------------------------------------
void updateAllDebuggerWindows( void )
void updateAllDebuggerWindows( enum QAsmView::UpdateType type )
{
if ( dbgWin )
{
dbgWin->queueUpdate();
dbgWin->queueUpdate(type);
}
}
//----------------------------------------------------------------------------

View File

@ -167,6 +167,8 @@ class QAsmView : public QWidget
QFont getFont(void){ return font; };
enum UpdateType { UPDATE_NONE, UPDATE_ALL, UPDATE_NO_SCROLL };
protected:
bool event(QEvent *event) override;
void paintEvent(QPaintEvent *event) override;
@ -471,7 +473,7 @@ class ConsoleDebugger : public QDialog
ConsoleDebugger(QWidget *parent = 0);
~ConsoleDebugger(void);
void updateWindowData(void);
void updateWindowData(enum QAsmView::UpdateType type);
void updateRegisterView(void);
void updateTabVisibility(void);
void breakPointNotify(int bpNum);
@ -480,7 +482,7 @@ class ConsoleDebugger : public QDialog
void setBookmarkSelectedAddress( int addr );
int getBookmarkSelectedAddress(void){ return selBmAddrVal; };
void edit_BM_name( int addr );
void queueUpdate(void);
void queueUpdate(enum QAsmView::UpdateType type);
QLabel *asmLineSelLbl;
@ -573,7 +575,8 @@ class ConsoleDebugger : public QDialog
ColorMenuItem *pcColorAct;
int selBmAddrVal;
bool windowUpdateReq;
enum QAsmView::UpdateType windowUpdateReq;
bool startedTraceLogger;
private:
@ -668,6 +671,6 @@ void saveGameDebugBreakpoints( bool force = false );
void loadGameDebugBreakpoints(void);
void debuggerClearAllBreakpoints(void);
void debuggerClearAllBookmarks(void);
void updateAllDebuggerWindows(void);
void updateAllDebuggerWindows(enum QAsmView::UpdateType type);
extern debuggerBookmarkManager_t dbgBmMgr;

View File

@ -399,7 +399,7 @@ static int writeMem( int mode, unsigned int addr, int value )
{
if (debuggerWindowIsOpen())
{
updateAllDebuggerWindows();
updateAllDebuggerWindows(QAsmView::UPDATE_NO_SCROLL);
}
}
@ -1853,7 +1853,7 @@ void HexEditorDialog_t::openDebugSymbolEditWindow( int addr )
if ( ret == QDialog::Accepted )
{
updateAllDebuggerWindows();
updateAllDebuggerWindows(QAsmView::UPDATE_NO_SCROLL);
}
}
//----------------------------------------------------------------------------
@ -2830,6 +2830,7 @@ void QHexEdit::keyPressEvent(QKeyEvent *event)
}
else
{ // Edit Area is Hex
key = int(event->text()[0].toUpper().toLatin1());
if ( ::isxdigit( key ) )

View File

@ -57,6 +57,7 @@
#include "common/os_utils.h"
#include "Qt/ConsoleDebugger.h"
#include "Qt/ConsoleWindow.h"
#include "Qt/ConsoleUtilities.h"
#include "Qt/TraceLogger.h"
@ -2187,7 +2188,7 @@ void QTraceLogView::openBpEditWindow(int editIdx, watchpointinfo *wp, traceRecor
numWPs++;
}
updateAllDebuggerWindows();
updateAllDebuggerWindows(QAsmView::UPDATE_NO_SCROLL);
}
}
}
@ -2232,7 +2233,7 @@ void QTraceLogView::openDebugSymbolEditWindow(int addr, int bank)
if (ret == QDialog::Accepted)
{
updateAllDebuggerWindows();
updateAllDebuggerWindows(QAsmView::UPDATE_NO_SCROLL);
}
}
//----------------------------------------------------------------------------