QmlJSInspector: Query objects until root is parent

Change-Id: I239f028cbf450703cefd9dde584067ec1ce8032c
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
This commit is contained in:
Aurindam Jana
2012-04-02 08:00:39 +02:00
parent f864df8fd2
commit 1074f9a5e1
2 changed files with 28 additions and 7 deletions

View File

@@ -35,6 +35,7 @@
#include "qmljsinspectorclient.h"
#include "qmljsinspector.h"
#include <qmljsdebugclient/qmljsdebugclientconstants.h>
#include <debugger/debuggerplugin.h>
#include <debugger/debuggerrunner.h>
#include <debugger/qml/qmlengine.h>
@@ -174,13 +175,8 @@ void ClientProxy::onCurrentObjectsFetched(quint32 queryId, const QVariant &resul
QmlDebugObjectReference obj = qvariant_cast<QmlDebugObjectReference>(result);
m_fetchCurrentObjects.push_front(obj);
//If this is not a root object, check if we have the parent
QmlDebugObjectReference parent = objectReferenceForId(obj.parentId());
if (obj.parentId() != -1 && (parent.debugId() == -1 || parent.needsMoreData())) {
m_fetchCurrentObjectsQueryIds << fetchContextObject(
QmlDebugObjectReference(obj.parentId()));
if (!getObjectHierarchy(obj))
return;
}
foreach (const QmlDebugObjectReference &o, m_fetchCurrentObjects)
addObjectToTree(o);
@@ -188,6 +184,23 @@ void ClientProxy::onCurrentObjectsFetched(quint32 queryId, const QVariant &resul
m_fetchCurrentObjects.last());
}
bool ClientProxy::getObjectHierarchy(const QmlDebugObjectReference &obj)
{
QmlDebugObjectReference parent = objectReferenceForId(obj.parentId());
//for root object
if (obj.parentId() == -1)
return true;
//for other objects
if (parent.debugId() == -1 || parent.needsMoreData()) {
m_fetchCurrentObjectsQueryIds << fetchContextObject(
QmlDebugObjectReference(obj.parentId()));
} else {
return getObjectHierarchy(parent);
}
return false;
}
void ClientProxy::setSelectedItemsByDebugId(const QList<int> &debugIds)
{
if (!isConnected())
@@ -518,7 +531,14 @@ void ClientProxy::fetchContextObjectRecursive(
m_objectTreeQueryIds.clear();
}
foreach (const QmlDebugObjectReference & obj, context.objects()) {
quint32 queryId = fetchContextObject(obj);
quint32 queryId = 0;
using namespace QmlJsDebugClient::Constants;
if (m_engineClient->objectName() == QML_DEBUGGER &&
m_engineClient->serviceVersion() >= CURRENT_SUPPORTED_VERSION)
queryId = fetchContextObject(obj);
else
queryId = m_engineClient->queryObjectRecursive(obj);
if (queryId)
m_objectTreeQueryIds << queryId;
}

View File

@@ -158,6 +158,7 @@ private:
void objectTreeFetched(quint32 queryId, const QVariant &result);
void updateConnected();
void reloadEngines();
bool getObjectHierarchy(const QmlDebugObjectReference &obj);
QList<QmlDebugObjectReference> objectReferences(const QmlDebugObjectReference &objectRef) const;
QmlDebugObjectReference objectReferenceForId(int debugId, const QmlDebugObjectReference &ref) const;