forked from qt-creator/qt-creator
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 <hjk@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -214,6 +214,7 @@ public:
|
||||
}
|
||||
|
||||
QString partialVariable;
|
||||
bool qmlFocusOnFrame = true; // QTCREATORBUG-29874
|
||||
};
|
||||
|
||||
class Location
|
||||
|
@@ -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<int> ids = QList<int>(),
|
||||
bool includeSource = false, const QVariant filter = QVariant());
|
||||
@@ -216,6 +216,8 @@ public:
|
||||
|
||||
FileInProjectFinder fileFinder;
|
||||
|
||||
bool skipFocusOnNextHandleFrame = false;
|
||||
|
||||
private:
|
||||
ConsoleItem *constructLogItemTree(const QmlV8ObjectData &objectData, QList<int> &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" : <number>,
|
||||
// "type" : "request",
|
||||
// "command" : "frame",
|
||||
// "arguments" : { "number" : <frame number> }
|
||||
// }
|
||||
skipFocusOnNextHandleFrame = focusOnFrame;
|
||||
|
||||
DebuggerCommand cmd(FRAME);
|
||||
cmd.arg(NUMBER, stackIndexLookup.value(engine->stackHandler()->currentIndex()));
|
||||
@@ -2136,6 +2138,8 @@ void QmlEnginePrivate::handleFrame(const QVariantMap &response)
|
||||
currentFrameScopes.append(scopeIndex);
|
||||
this->scope(scopeIndex);
|
||||
}
|
||||
|
||||
if (skipFocusOnNextHandleFrame)
|
||||
engine->gotoLocation(stackHandler->currentFrame());
|
||||
|
||||
// Send watchers list
|
||||
|
Reference in New Issue
Block a user