diff --git a/src/libs/qmldebug/baseenginedebugclient.cpp b/src/libs/qmldebug/baseenginedebugclient.cpp index b53fe96ff30..9dc51c1084d 100644 --- a/src/libs/qmldebug/baseenginedebugclient.cpp +++ b/src/libs/qmldebug/baseenginedebugclient.cpp @@ -286,14 +286,14 @@ quint32 BaseEngineDebugClient::addWatch(const ObjectReference &object, return id; } -quint32 BaseEngineDebugClient::addWatch(int objectId) +quint32 BaseEngineDebugClient::addWatch(int objectDebugId) { quint32 id = 0; if (status() == Enabled) { id = getId(); QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_OBJECT") << id << objectId; + ds << QByteArray("WATCH_OBJECT") << id << objectDebugId; sendMessage(message); } return id; diff --git a/src/libs/qmldebug/baseenginedebugclient.h b/src/libs/qmldebug/baseenginedebugclient.h index 741ff8cfae8..4f050c26302 100644 --- a/src/libs/qmldebug/baseenginedebugclient.h +++ b/src/libs/qmldebug/baseenginedebugclient.h @@ -56,7 +56,7 @@ public: quint32 addWatch(const PropertyReference &property); quint32 addWatch(const ContextReference &context, const QString &id); quint32 addWatch(const ObjectReference &object, const QString &expr); - quint32 addWatch(int objectId); + quint32 addWatch(int objectDebugId); quint32 addWatch(const FileReference &file); void removeWatch(quint32 watch); diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index 67078e97813..1248c9b806c 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -989,10 +989,11 @@ bool QmlEngine::setToolTipExpression(const QPoint &mousePos, void QmlEngine::assignValueInDebugger(const WatchData *data, const QString &expression, const QVariant &valueV) { - if (!expression.isEmpty() && m_adapter.activeDebuggerClient()) { - m_adapter.activeDebuggerClient()->assignValueInDebugger(data, - expression, - valueV); + if (!expression.isEmpty()) { + if (data->isInspect() && m_inspectorAdapter.agent()) + m_inspectorAdapter.agent()->assignValue(data, expression, valueV); + else if (m_adapter.activeDebuggerClient()) + m_adapter.activeDebuggerClient()->assignValueInDebugger(data, expression, valueV); } } diff --git a/src/plugins/debugger/qml/qmlinspectoragent.cpp b/src/plugins/debugger/qml/qmlinspectoragent.cpp index 492fc5b7b2f..4afe525fd06 100644 --- a/src/plugins/debugger/qml/qmlinspectoragent.cpp +++ b/src/plugins/debugger/qml/qmlinspectoragent.cpp @@ -81,6 +81,23 @@ quint32 QmlInspectorAgent::queryExpressionResult(int debugId, m_engine.debugId()); } +void QmlInspectorAgent::assignValue(const WatchData *data, + const QString &expr, const QVariant &valueV) +{ + if (debug) + qDebug() << __FUNCTION__ << "(" << data->id << ")" << data->iname; + + if (data->id) { + QString val(valueV.toString()); + if (valueV.type() == QVariant::String) { + val = val.replace(QLatin1Char('\"'), QLatin1String("\\\"")); + val = QLatin1Char('\"') + val + QLatin1Char('\"'); + } + QString expression = QString(_("%1 = %2;")).arg(expr).arg(val); + queryExpressionResult(data->id, expression); + } +} + void QmlInspectorAgent::updateWatchData(const WatchData &data) { if (debug) @@ -269,7 +286,7 @@ bool QmlInspectorAgent::addObjectWatch(int objectDebugId) if (m_engineClient->addWatch(objectDebugId)) m_objectWatches.append(objectDebugId); - return false; + return true; } bool QmlInspectorAgent::isObjectBeingWatched(int objectDebugId) @@ -316,6 +333,8 @@ void QmlInspectorAgent::setEngineClient(BaseEngineDebugClient *client) this, SLOT(onResult(quint32,QVariant,QByteArray))); disconnect(m_engineClient, SIGNAL(newObject(int,int,int)), this, SLOT(newObject(int,int,int))); + disconnect(m_engineClient, SIGNAL(valueChanged(int,QByteArray,QVariant)), + this, SLOT(onValueChanged(int,QByteArray,QVariant))); } m_engineClient = client; @@ -327,6 +346,8 @@ void QmlInspectorAgent::setEngineClient(BaseEngineDebugClient *client) this, SLOT(onResult(quint32,QVariant,QByteArray))); connect(m_engineClient, SIGNAL(newObject(int,int,int)), this, SLOT(newObject(int,int,int))); + connect(m_engineClient, SIGNAL(valueChanged(int,QByteArray,QVariant)), + this, SLOT(onValueChanged(int,QByteArray,QVariant))); } updateStatus(); @@ -418,6 +439,21 @@ void QmlInspectorAgent::newObject(int engineId, int objectId, int /*parentId*/) m_delayQueryTimer.start(); } +void QmlInspectorAgent::onValueChanged(int debugId, const QByteArray &propertyName, + const QVariant &value) +{ + const QByteArray iname = m_debugIdToIname.value(debugId) + + ".[properties]." + propertyName; + const WatchData *data = m_debuggerEngine->watchHandler()->findData(iname); + if (debug) + qDebug() << __FUNCTION__ << "(" << debugId << ")" << iname <watchHandler()->insertData(d); + } +} + void QmlInspectorAgent::reloadEngines() { if (debug) @@ -660,6 +696,7 @@ QList QmlInspectorAgent::buildWatchData(const ObjectReference &obj, list.append(objWatch); m_debugIdToIname.insert(objWatch.id, objWatch.iname); + addObjectWatch(objWatch.id); if (m_engineClient->objectName() != QmlDebug::Constants::QML_DEBUGGER) { QList childIds; @@ -694,6 +731,7 @@ QList QmlInspectorAgent::buildWatchData(const ObjectReference &obj, foreach (const PropertyReference &property, obj.properties()) { WatchData propertyWatch; + propertyWatch.id = objWatch.id; propertyWatch.exp = property.name().toLatin1(); propertyWatch.name = property.name(); propertyWatch.iname = buildIName(propertiesWatch.iname, property.name()); @@ -744,6 +782,9 @@ void QmlInspectorAgent::clearObjectTree() m_debugIdToIname.clear(); m_debugIdChildIds.clear(); m_objectStack.clear(); + + removeAllObjectWatches(); } } // Internal } // Debugger + diff --git a/src/plugins/debugger/qml/qmlinspectoragent.h b/src/plugins/debugger/qml/qmlinspectoragent.h index 5273e4593a2..87f26f6a8ee 100644 --- a/src/plugins/debugger/qml/qmlinspectoragent.h +++ b/src/plugins/debugger/qml/qmlinspectoragent.h @@ -62,6 +62,7 @@ public: void fetchObject(int debugId); quint32 queryExpressionResult(int debugId, const QString &expression); + void assignValue(const WatchData *data, const QString &expression, const QVariant &valueV); void updateWatchData(const WatchData &data); void selectObjectInTree(int debugId); @@ -105,6 +106,7 @@ private slots: void updateStatus(); void onResult(quint32 queryId, const QVariant &value, const QByteArray &type); void newObject(int engineId, int objectId, int parentId); + void onValueChanged(int debugId, const QByteArray &propertyName, const QVariant &value); private: void reloadEngines(); diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 71e97113b85..890f68456f1 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -1139,12 +1139,13 @@ Qt::ItemFlags WatchModel::flags(const QModelIndex &idx) const = Qt::ItemIsSelectable | Qt::ItemIsEnabled; static const Qt::ItemFlags editable = notEditable | Qt::ItemIsEditable; - // Disable editing if debuggee is positively running. + // Disable editing if debuggee is positively running except for Inspector data + const WatchData &data = *watchItem(idx); const bool isRunning = engine() && engine()->state() == InferiorRunOk; - if (isRunning && engine() && !engine()->hasCapability(AddWatcherWhileRunningCapability)) + if (isRunning && engine() && !engine()->hasCapability(AddWatcherWhileRunningCapability) && + !data.isInspect()) return notEditable; - const WatchData &data = *watchItem(idx); if (data.isWatcher()) { if (idx.column() == 0 && data.iname.count('.') == 1) return editable; // Watcher names are editable. @@ -1159,6 +1160,9 @@ Qt::ItemFlags WatchModel::flags(const QModelIndex &idx) const } else if (data.isLocal()) { if (idx.column() == 1 && data.valueEditable) return editable; // Locals values are sometimes editable. + } else if (data.isInspect()) { + if (idx.column() == 1 && data.valueEditable) + return editable; // Inspector values are sometimes editable. } return notEditable; }