diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index 0e5c44bb7b96144eac37b9028f6a7035c702f9b6..0107efd6ae3638562361c68fdb26d6afed93cedd 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -517,7 +517,19 @@ void QmlEngine::setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEd void QmlEngine::assignValueInDebugger(const QString &expression, const QString &value) { - XSDEBUG("ASSIGNING: " << expression + '=' + value); + QRegExp inObject("@([0-9a-fA-F]+)->(.+)"); + if (inObject.exactMatch(expression)) { + bool ok = false; + quint64 objectId = inObject.cap(1).toULongLong(&ok, 16); + QString property = inObject.cap(2); + if (ok && objectId > 0 && !property.isEmpty()) { + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); + rs << QByteArray("SET_PROPERTY"); + rs << expression.toUtf8() << objectId << property << value; + sendMessage(reply); + } + } } void QmlEngine::updateWatchData(const WatchData &data) diff --git a/src/tools/qml/qmlobserver/jsdebuggeragent.cpp b/src/tools/qml/qmlobserver/jsdebuggeragent.cpp index 966b6691deddc17571b4f8405854554ef57a73f0..bf54f101e078ffba395ad5ca5d38d58910733be5 100644 --- a/src/tools/qml/qmlobserver/jsdebuggeragent.cpp +++ b/src/tools/qml/qmlobserver/jsdebuggeragent.cpp @@ -121,6 +121,7 @@ static QList<JSAgentWatchData> expandObject(const QScriptValue &object) { QList<JSAgentWatchData> result; QScriptValueIterator it(object); + QByteArray expPrefix = '@' + QByteArray::number(object.objectId(), 16) + "->"; while (it.hasNext()) { it.next(); if (it.flags() & QScriptValue::SkipInEnumeration) @@ -130,7 +131,9 @@ static QList<JSAgentWatchData> expandObject(const QScriptValue &object) // and it is not usefull in the debugger. continue; } - result << JSAgentWatchData::fromScriptValue(it.name(), it.value()); + JSAgentWatchData data = JSAgentWatchData::fromScriptValue(it.name(), it.value()); + data.exp.prepend(expPrefix); + result << data; } return result; } @@ -368,6 +371,31 @@ void JSDebuggerAgent::messageReceived(const QByteArray& message) QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("LOCALS") << frameId << locals; sendMessage(reply); + + } else if (command == "SET_PROPERTY") { + State oldState = state; + state = Stopped; + + QByteArray id; + qint64 objectId; + QString property; + QString value; + ds >> id >> objectId >> property >> value; + + if (knownObjectIds.contains(objectId)) { + QScriptValue object; + object = engine()->objectById(objectId); + + if(object.isObject()) { + QScriptValue result = engine()->evaluate(value); + object.setProperty(property, result); + } + + // Clear any exceptions occurred during locals evaluation. + engine()->clearExceptions(); + } + state = oldState; + //TODO: feedback } else { qDebug() << Q_FUNC_INFO << "Unknown command" << command; } @@ -414,6 +442,7 @@ void JSDebuggerAgent::stopped() recordKnownObjects(watches); recordKnownObjects(locals); + knownObjectIds << activationObject.objectId(); // Clear any exceptions occurred during locals evaluation. engine()->clearExceptions();