From 08546615f223cc1008c244ea37672986ca0e7aa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20De=20Canni=C3=A8re?= Date: Thu, 9 Nov 2023 10:37:34 +0100 Subject: [PATCH] Qml Debugger: Do not focus the current frame when adding a watch The other debuggers do not cause the view to jump to the current frame when adding a watch. Make the Qml debugger also not do this. This is done in a slightly hacky way by preventing the gotoLocation of the next handleFrame call to be executed. Ideally, the logic to retrieve the value of locals should be separated from the logic to jump to a specific frame. Right now the jump is implicit when updating the locals. Fixes: QTCREATORBUG-29329 Change-Id: I4b8f5c99ae41c92c3394f86da481303d4765f897 Reviewed-by: hjk Reviewed-by: Fabian Kosmale --- src/plugins/debugger/debuggerengine.cpp | 1 + src/plugins/debugger/debuggerengine.h | 1 + src/plugins/debugger/qml/qmlengine.cpp | 16 ++++++++++------ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 04befbf071c..72bdb341a3e 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -2411,6 +2411,7 @@ void DebuggerEngine::updateWatchData(const QString &iname) // e.g. when changing the expression in a watcher. UpdateParameters params; params.partialVariable = iname; + params.qmlFocusOnFrame = false; doUpdateLocals(params); } diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index 354ebb95fe0..aed61bbc2e4 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -214,6 +214,7 @@ public: } QString partialVariable; + bool qmlFocusOnFrame = true; // QTCREATORBUG-29874 }; class Location diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index d418d9cb4dc..3f18b5f5fc8 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -141,7 +141,7 @@ public: void evaluate(const QString expr, qint64 context, const QmlCallback &cb); void lookup(const LookupItems &items); void backtrace(); - void updateLocals(); + void updateLocals(bool focusOnFrame = true); void scope(int number, int frameNumber = -1); void scripts(int types = 4, const QList ids = QList(), bool includeSource = false, const QVariant filter = QVariant()); @@ -216,6 +216,8 @@ public: FileInProjectFinder fileFinder; + bool skipFocusOnNextHandleFrame = false; + private: ConsoleItem *constructLogItemTree(const QmlV8ObjectData &objectData, QList &seenHandles); void constructChildLogItems(ConsoleItem *item, const QmlV8ObjectData &objectData, @@ -791,7 +793,7 @@ void QmlEngine::assignValueInDebugger(WatchItem *item, StackHandler *handler = stackHandler(); QString exp = QString("%1 = %2;").arg(expression).arg(value.toString()); if (handler->isContentsValid() && handler->currentFrame().isUsable()) { - d->evaluate(exp, -1, [this](const QVariantMap &) { d->updateLocals(); }); + d->evaluate(exp, -1, [this](const QVariantMap &) { d->updateLocals(false); }); } else { showMessage(Tr::tr("Cannot evaluate %1 in current stack frame.") .arg(expression), ConsoleOutput); @@ -941,8 +943,7 @@ void QmlEngine::quitDebugger() void QmlEngine::doUpdateLocals(const UpdateParameters ¶ms) { - Q_UNUSED(params) - d->updateLocals(); + d->updateLocals(params.qmlFocusOnFrame); } Context QmlEngine::languageContext() const @@ -1292,13 +1293,14 @@ void QmlEnginePrivate::backtrace() runCommand(cmd, CB(handleBacktrace)); } -void QmlEnginePrivate::updateLocals() +void QmlEnginePrivate::updateLocals(bool focusOnFrame) { // { "seq" : , // "type" : "request", // "command" : "frame", // "arguments" : { "number" : } // } + skipFocusOnNextHandleFrame = focusOnFrame; DebuggerCommand cmd(FRAME); cmd.arg(NUMBER, stackIndexLookup.value(engine->stackHandler()->currentIndex())); @@ -2136,7 +2138,9 @@ void QmlEnginePrivate::handleFrame(const QVariantMap &response) currentFrameScopes.append(scopeIndex); this->scope(scopeIndex); } - engine->gotoLocation(stackHandler->currentFrame()); + + if (skipFocusOnNextHandleFrame) + engine->gotoLocation(stackHandler->currentFrame()); // Send watchers list if (stackHandler->isContentsValid() && stackHandler->currentFrame().isUsable()) {