diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/qmljsinspector/qmljsclientproxy.cpp | 121 | ||||
-rw-r--r-- | src/plugins/qmljsinspector/qmljsclientproxy.h | 8 | ||||
-rw-r--r-- | src/plugins/qmljsinspector/qmljsinspector.cpp | 10 | ||||
-rw-r--r-- | src/plugins/qmljsinspector/qmljsinspector.h | 1 | ||||
-rw-r--r-- | src/plugins/qmljsinspector/qmljslivetextpreview.cpp | 44 | ||||
-rw-r--r-- | src/plugins/qmljsinspector/qmljslivetextpreview.h | 2 |
6 files changed, 91 insertions, 95 deletions
diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.cpp b/src/plugins/qmljsinspector/qmljsclientproxy.cpp index 3a923a12f0..6dbecc62bc 100644 --- a/src/plugins/qmljsinspector/qmljsclientproxy.cpp +++ b/src/plugins/qmljsinspector/qmljsclientproxy.cpp @@ -51,7 +51,6 @@ ClientProxy::ClientProxy(Debugger::Internal::QmlAdapter *adapter, QObject *paren , m_designClient(0) , m_engineQuery(0) , m_contextQuery(0) - , m_objectTreeQuery(0) { connect(m_adapter, SIGNAL(aboutToDisconnect()), SLOT(disconnectFromServer())); @@ -125,24 +124,16 @@ void ClientProxy::disconnectFromServer() delete m_contextQuery; m_contextQuery = 0; - if (m_objectTreeQuery) { - delete m_objectTreeQuery; - m_objectTreeQuery = 0; - } + qDeleteAll(m_objectTreeQuery); + m_objectTreeQuery.clear(); } void ClientProxy::refreshObjectTree() { - if (!m_objectTreeQuery) { - m_objectTreeQuery = m_client->queryObjectRecursive(m_rootObject, this); - - if (!m_objectTreeQuery->isWaiting()) { - objectTreeFetched(m_objectTreeQuery->state()); - } else { - connect(m_objectTreeQuery, - SIGNAL(stateChanged(QDeclarativeDebugQuery::State)), - SLOT(objectTreeFetched(QDeclarativeDebugQuery::State))); - } + if (!m_contextQuery) { + qDeleteAll(m_objectTreeQuery); + m_objectTreeQuery.clear(); + queryEngineContext(m_engines.value(0).debugId()); } } @@ -154,30 +145,18 @@ void ClientProxy::onCurrentObjectsChanged(const QList< int >& debugIds, bool req QDeclarativeDebugObjectReference ref = objectReferenceForId(debugId); if (ref.debugId() != -1) { selectedItems << ref; - } else { + } else if (requestIfNeeded) { // ### FIXME right now, there's no way in the protocol to // a) get some item and know its parent (although that's possible // by adding it to a separate plugin) // b) add children to part of an existing tree. // So the only choice that remains is to update the complete // tree when we have an unknown debug id. - if (!m_objectTreeQuery && requestIfNeeded) - m_objectTreeQuery = m_client->queryObjectRecursive(m_rootObject, this); - break; + // break; } } - if (m_objectTreeQuery) { - if (!m_objectTreeQuery->isWaiting()) { - objectTreeFetched(m_objectTreeQuery->state()); - } else { - connect(m_objectTreeQuery, - SIGNAL(stateChanged(QDeclarativeDebugQuery::State)), - SLOT(objectTreeFetched(QDeclarativeDebugQuery::State))); - } - } else { - emit selectedItemsChanged(selectedItems); - } + emit selectedItemsChanged(selectedItems); } void ClientProxy::setSelectedItemsByObjectId(const QList<QDeclarativeDebugObjectReference> &objectRefs) @@ -188,12 +167,17 @@ void ClientProxy::setSelectedItemsByObjectId(const QList<QDeclarativeDebugObject QDeclarativeDebugObjectReference ClientProxy::objectReferenceForId(int debugId) const { - return objectReferenceForId(debugId, m_rootObject); + foreach (const QDeclarativeDebugObjectReference& it, m_rootObjects) { + QDeclarativeDebugObjectReference result = objectReferenceForId(debugId, it); + if (result.debugId() == debugId) + return result; + } + return QDeclarativeDebugObjectReference(); } -QDeclarativeDebugObjectReference QmlJSInspector::Internal::ClientProxy::rootObjectReference() const +QList<QDeclarativeDebugObjectReference> QmlJSInspector::Internal::ClientProxy::rootObjectReference() const { - return m_rootObject; + return m_rootObjects; } QDeclarativeDebugObjectReference ClientProxy::objectReferenceForId(int debugId, @@ -213,7 +197,11 @@ QDeclarativeDebugObjectReference ClientProxy::objectReferenceForId(int debugId, QList<QDeclarativeDebugObjectReference> ClientProxy::objectReferences(const QUrl &url) const { - return objectReferences(url, m_rootObject); + QList<QDeclarativeDebugObjectReference> result; + foreach(const QDeclarativeDebugObjectReference &it, m_rootObjects) { + result.append(objectReferences(url, it)); + } + return result; } QList<QDeclarativeDebugObjectReference> ClientProxy::objectReferences(const QUrl &url, @@ -291,24 +279,28 @@ void ClientProxy::queryEngineContext(int id) void ClientProxy::contextChanged() { if (m_contextQuery) { - - if (m_contextQuery->rootContext().objects().isEmpty()) { - m_rootObject = QDeclarativeDebugObjectReference(); - emit objectTreeUpdated(m_rootObject); - } else { - m_rootObject = m_contextQuery->rootContext().objects().last(); - } - + m_rootObjects = m_contextQuery->rootContext().objects(); delete m_contextQuery; m_contextQuery = 0; - m_objectTreeQuery = m_client->queryObjectRecursive(m_rootObject, this); - if (!m_objectTreeQuery->isWaiting()) { - objectTreeFetched(); - } else { - connect(m_objectTreeQuery, - SIGNAL(stateChanged(QDeclarativeDebugQuery::State)), - SLOT(objectTreeFetched(QDeclarativeDebugQuery::State))); + if (m_rootObjects.isEmpty()) { + emit objectTreeUpdated(); + return; + } + + qDeleteAll(m_objectTreeQuery); + m_objectTreeQuery.clear(); + + foreach(const QDeclarativeDebugObjectReference & obj, m_rootObjects) { + QDeclarativeDebugObjectQuery* query = m_client->queryObjectRecursive(obj, this); + if (!query->isWaiting()) { + query->deleteLater(); //ignore errors; + } else { + m_objectTreeQuery << query; + connect(query, + SIGNAL(stateChanged(QDeclarativeDebugQuery::State)), + SLOT(objectTreeFetched(QDeclarativeDebugQuery::State))); + } } } @@ -316,30 +308,29 @@ void ClientProxy::contextChanged() void ClientProxy::objectTreeFetched(QDeclarativeDebugQuery::State state) { - if (state == QDeclarativeDebugQuery::Error) { - delete m_objectTreeQuery; - m_objectTreeQuery = 0; - } - - if (state != QDeclarativeDebugQuery::Completed) { - m_rootObject = QDeclarativeDebugObjectReference(); + QDeclarativeDebugObjectQuery *query = qobject_cast<QDeclarativeDebugObjectQuery *>(sender()); + if (!query || state == QDeclarativeDebugQuery::Error) { + delete query; return; } - m_rootObject = m_objectTreeQuery->object(); + m_rootObjects.append(query->object()); - delete m_objectTreeQuery; - m_objectTreeQuery = 0; + int removed = m_objectTreeQuery.removeAll(query); + Q_ASSERT(removed == 1); + Q_UNUSED(removed); + delete query; - emit objectTreeUpdated(m_rootObject); + if (m_objectTreeQuery.isEmpty()) { + emit objectTreeUpdated(); - if (isDesignClientConnected()) { - if (!m_designClient->selectedItemIds().isEmpty()) - onCurrentObjectsChanged(m_designClient->selectedItemIds(), false); + if (isDesignClientConnected()) { + if (!m_designClient->selectedItemIds().isEmpty()) + onCurrentObjectsChanged(m_designClient->selectedItemIds(), false); - m_designClient->setObjectIdList(QList<QDeclarativeDebugObjectReference>() << m_rootObject); + m_designClient->setObjectIdList(m_rootObjects); + } } - } void ClientProxy::reloadQmlViewer() diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.h b/src/plugins/qmljsinspector/qmljsclientproxy.h index 2654a74ba7..2426e6853a 100644 --- a/src/plugins/qmljsinspector/qmljsclientproxy.h +++ b/src/plugins/qmljsinspector/qmljsclientproxy.h @@ -66,7 +66,7 @@ public: // returns the object references for the given url. QList<QDeclarativeDebugObjectReference> objectReferences(const QUrl &url = QUrl()) const; QDeclarativeDebugObjectReference objectReferenceForId(int debugId) const; - QDeclarativeDebugObjectReference rootObjectReference() const; + QList<QDeclarativeDebugObjectReference> rootObjectReference() const; bool isConnected() const; @@ -77,7 +77,7 @@ public: Debugger::Internal::QmlAdapter *qmlAdapter() const; signals: - void objectTreeUpdated(const QDeclarativeDebugObjectReference &rootObject); + void objectTreeUpdated(); void connectionStatusMessage(const QString &text); void aboutToReloadEngines(); @@ -141,9 +141,9 @@ private: QDeclarativeDebugEnginesQuery *m_engineQuery; QDeclarativeDebugRootContextQuery *m_contextQuery; - QDeclarativeDebugObjectQuery *m_objectTreeQuery; + QList<QDeclarativeDebugObjectQuery *> m_objectTreeQuery; - QDeclarativeDebugObjectReference m_rootObject; + QList<QDeclarativeDebugObjectReference> m_rootObjects; QList<QDeclarativeDebugEngineReference> m_engines; }; diff --git a/src/plugins/qmljsinspector/qmljsinspector.cpp b/src/plugins/qmljsinspector/qmljsinspector.cpp index 76726bfb3d..eedbd5ec32 100644 --- a/src/plugins/qmljsinspector/qmljsinspector.cpp +++ b/src/plugins/qmljsinspector/qmljsinspector.cpp @@ -206,14 +206,14 @@ void InspectorUi::disconnected() void InspectorUi::updateEngineList() { - m_engines = m_clientProxy->engines(); + QList<QDeclarativeDebugEngineReference> engines = m_clientProxy->engines(); //#warning update the QML engines combo - if (m_engines.isEmpty()) + if (engines.isEmpty()) qWarning("qmldebugger: no engines found!"); else { - const QDeclarativeDebugEngineReference engine = m_engines.first(); + const QDeclarativeDebugEngineReference engine = engines.first(); m_clientProxy->queryEngineContext(engine.debugId()); } } @@ -254,7 +254,7 @@ void InspectorUi::serverReloaded() Document::Ptr doc = snapshot.document(it.key()); it.value()->resetInitialDoc(doc); } - m_clientProxy->queryEngineContext(m_engines.value(0).debugId()); + m_clientProxy->refreshObjectTree(); } @@ -293,7 +293,7 @@ void InspectorUi::createPreviewForEditor(Core::IEditor *newEditor) m_textPreviews.insert(newEditor->file()->fileName(), preview); preview->associateEditor(newEditor); - preview->updateDebugIds(m_clientProxy->rootObjectReference()); + preview->updateDebugIds(); } } } diff --git a/src/plugins/qmljsinspector/qmljsinspector.h b/src/plugins/qmljsinspector/qmljsinspector.h index 6917dc2d17..b7b5020a2a 100644 --- a/src/plugins/qmljsinspector/qmljsinspector.h +++ b/src/plugins/qmljsinspector/qmljsinspector.h @@ -148,7 +148,6 @@ private: ProjectExplorer::Project *m_debugProject; static InspectorUi *m_instance; - QList<QDeclarativeDebugEngineReference> m_engines; }; } // Internal diff --git a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp index 2e66d4e112..3a731d6516 100644 --- a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp +++ b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp @@ -71,7 +71,7 @@ class MapObjectWithDebugReference : public Visitor virtual bool visit(UiObjectDefinition *ast) ; virtual bool visit(UiObjectBinding *ast) ; - QDeclarativeDebugObjectReference root; + QList<QDeclarativeDebugObjectReference> root; QString filename; QHash<UiObjectMember *, DebugIdList> result; QSet<QmlJS::AST::UiObjectMember *> lookupObjects; @@ -97,16 +97,21 @@ bool MapObjectWithDebugReference::visit(UiObjectBinding* ast) void MapObjectWithDebugReference::endVisit(UiObjectDefinition* ast) { - if (lookupObjects.isEmpty() || activated) - processRecursive(root, ast); + if (lookupObjects.isEmpty() || activated) { + foreach(const QDeclarativeDebugObjectReference& it, root) + processRecursive(it, ast); + } if (lookupObjects.contains(ast)) activated--; } + void MapObjectWithDebugReference::endVisit(UiObjectBinding* ast) { - if (lookupObjects.isEmpty() || activated) - processRecursive(root, ast); + if (lookupObjects.isEmpty() || activated) { + foreach(const QDeclarativeDebugObjectReference& it, root) + processRecursive(it, ast); + } if (lookupObjects.contains(ast)) activated--; @@ -184,9 +189,7 @@ QmlJSLiveTextPreview::QmlJSLiveTextPreview(const QmlJS::Document::Ptr &doc, SLOT(documentChanged(QmlJS::Document::Ptr))); if (m_clientProxy.data()) { - connect(m_clientProxy.data(), - SIGNAL(objectTreeUpdated(QDeclarativeDebugObjectReference)), - SLOT(updateDebugIds(QDeclarativeDebugObjectReference))); + connect(m_clientProxy.data(), SIGNAL(objectTreeUpdated()), SLOT(updateDebugIds())); } } @@ -279,15 +282,19 @@ static QList<int> findRootObjectRecursive(const QDeclarativeDebugObjectReference return result; } -void QmlJSLiveTextPreview::updateDebugIds(const QDeclarativeDebugObjectReference &rootReference) +void QmlJSLiveTextPreview::updateDebugIds() { if (!m_initialDoc->qmlProgram()) return; + ClientProxy* clientProxy = m_clientProxy.data(); + if (!clientProxy) + return; + { // Map all the object that comes from the document as it has been loaded by the server. const QmlJS::Document::Ptr &doc = m_initialDoc; MapObjectWithDebugReference visitor; - visitor.root = rootReference; + visitor.root = clientProxy->rootObjectReference(); visitor.filename = doc->fileName(); doc->qmlProgram()->accept(&visitor); @@ -305,7 +312,9 @@ void QmlJSLiveTextPreview::updateDebugIds(const QDeclarativeDebugObjectReference // Map the root nodes of the document. if(doc->qmlProgram()->members && doc->qmlProgram()->members->member) { UiObjectMember* root = doc->qmlProgram()->members->member; - QList<int> r = findRootObjectRecursive(rootReference, doc); + QList<int> r; + foreach(const QDeclarativeDebugObjectReference& it, clientProxy->rootObjectReference()) + r += findRootObjectRecursive(it, doc); if (!r.isEmpty()) m_debugIds[root] += r; } @@ -316,7 +325,7 @@ void QmlJSLiveTextPreview::updateDebugIds(const QDeclarativeDebugObjectReference const QmlJS::Document::Ptr &doc = it.key(); MapObjectWithDebugReference visitor; - visitor.root = rootReference; + visitor.root = clientProxy->rootObjectReference(); visitor.filename = doc->fileName(); visitor.lookupObjects = it.value(); visitor.doc = doc; @@ -651,18 +660,15 @@ void QmlJSLiveTextPreview::setApplyChangesToQmlObserver(bool applyChanges) void QmlJSLiveTextPreview::setClientProxy(ClientProxy *clientProxy) { if (m_clientProxy.data()) { - disconnect(m_clientProxy.data(), - SIGNAL(objectTreeUpdated(QDeclarativeDebugObjectReference)), - this, - SLOT(updateDebugIds(QDeclarativeDebugObjectReference))); + disconnect(m_clientProxy.data(), SIGNAL(objectTreeUpdated()), + this, SLOT(updateDebugIds())); } m_clientProxy = clientProxy; if (m_clientProxy.data()) { - connect(m_clientProxy.data(), - SIGNAL(objectTreeUpdated(QDeclarativeDebugObjectReference)), - SLOT(updateDebugIds(QDeclarativeDebugObjectReference))); + connect(m_clientProxy.data(), SIGNAL(objectTreeUpdated()), + SLOT(updateDebugIds())); } } diff --git a/src/plugins/qmljsinspector/qmljslivetextpreview.h b/src/plugins/qmljsinspector/qmljslivetextpreview.h index 63f471cc55..0681e6e2cb 100644 --- a/src/plugins/qmljsinspector/qmljslivetextpreview.h +++ b/src/plugins/qmljsinspector/qmljslivetextpreview.h @@ -90,7 +90,7 @@ signals: public slots: void setApplyChangesToQmlObserver(bool applyChanges); - void updateDebugIds(const QDeclarativeDebugObjectReference &rootReference); + void updateDebugIds(); private slots: void changeSelectedElements(QList<int> offsets, const QString &wordAtCursor); |