From 85801227a9b27234e6107268aa15d26e103a3f3a Mon Sep 17 00:00:00 2001 From: Christiaan Janssen Date: Wed, 20 Apr 2011 16:47:47 +0200 Subject: [PATCH] QmlDebugger: keeping watches when changing stack frames Reviewed-by: Kai Koehne --- .../qml/qmljsdebugger/jsdebuggeragent.cpp | 12 +++++++++++- src/plugins/debugger/qml/qmlengine.cpp | 19 +++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/share/qtcreator/qml/qmljsdebugger/jsdebuggeragent.cpp b/share/qtcreator/qml/qmljsdebugger/jsdebuggeragent.cpp index 170bf482b9a..958012d92ef 100644 --- a/share/qtcreator/qml/qmljsdebugger/jsdebuggeragent.cpp +++ b/share/qtcreator/qml/qmljsdebugger/jsdebuggeragent.cpp @@ -538,11 +538,21 @@ void JSDebuggerAgentPrivate::messageReceived(const QByteArray &message) deep++; } + QList watches; QList locals = getLocals(ctx); + // re-evaluate watches given the frame's context + QScriptContext *currentCtx = engine()->pushContext(); + currentCtx->setActivationObject(ctx->activationObject()); + currentCtx->setThisObject(ctx->thisObject()); + foreach (const QString &expr, watchExpressions) + watches << fromScriptValue(expr, engine()->evaluate(expr)); + recordKnownObjects(watches); + engine()->popContext(); + QByteArray reply; QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("LOCALS") << frameId << locals; + rs << QByteArray("LOCALS") << frameId << locals << watches; sendMessage(reply); } else if (command == "SET_PROPERTY") { SetupExecEnv execEnv(this); diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index 33d8f9947b5..ed0d0d677e6 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -949,14 +949,29 @@ void QmlEngine::messageReceived(const QByteArray &message) sendPing(); } else if (command == "LOCALS") { QList locals; + QList watches; int frameId; stream >> frameId >> locals; + if (!stream.atEnd()) { // compatibility with jsdebuggeragent from 2.1, 2.2 + stream >> watches; + } - logMessage(LogReceive, QString("%1 %2 (%3 x locals)").arg( + logMessage(LogReceive, QString("%1 %2 (%3 x locals) (%4 x watchdata)").arg( QString(command), QString::number(frameId), - QString::number(locals.size()))); + QString::number(locals.size()), + QString::number(watches.size()))); watchHandler()->beginCycle(); bool needPing = false; + foreach (WatchData data, watches) { + data.iname = watchHandler()->watcherName(data.exp); + watchHandler()->insertData(data); + + if (watchHandler()->expandedINames().contains(data.iname)) { + needPing = true; + expandObject(data.iname, data.id); + } + } + foreach (WatchData data, locals) { data.iname = "local." + data.exp; watchHandler()->insertData(data);