Commit 85801227 authored by Christiaan Janssen's avatar Christiaan Janssen
Browse files

QmlDebugger: keeping watches when changing stack frames

Reviewed-by: Kai Koehne
parent 01ad0840
......@@ -538,11 +538,21 @@ void JSDebuggerAgentPrivate::messageReceived(const QByteArray &message)
deep++;
}
QList<JSAgentWatchData> watches;
QList<JSAgentWatchData> 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);
......
......@@ -949,14 +949,29 @@ void QmlEngine::messageReceived(const QByteArray &message)
sendPing();
} else if (command == "LOCALS") {
QList<WatchData> locals;
QList<WatchData> 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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment