From bd5fe5243b3c3fa48cf221975eadd6b30c326afb Mon Sep 17 00:00:00 2001 From: Simjees Abraham Date: Fri, 25 May 2012 09:33:02 +0200 Subject: [PATCH] Debugger: Change in response for message "destroyObject". Response for "destroyObject" now has the debugId of the destroyed object. This is used to fetch the parent object rather than querying the engine context. Change-Id: I2e5b7650cbe847117cce6952206dd479ee696f0e Reviewed-by: Aurindam Jana --- src/libs/qmldebug/basetoolsclient.h | 2 +- src/libs/qmldebug/qmltoolsclient.cpp | 11 ++++++++--- .../debugger/qml/qmlinspectoradapter.cpp | 6 +++--- src/plugins/debugger/qml/qmlinspectoradapter.h | 2 +- src/plugins/debugger/qml/qmlinspectoragent.cpp | 18 ++++++++++++++++++ src/plugins/debugger/qml/qmlinspectoragent.h | 1 + 6 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/libs/qmldebug/basetoolsclient.h b/src/libs/qmldebug/basetoolsclient.h index 0e3ef774455..e74b7510adf 100644 --- a/src/libs/qmldebug/basetoolsclient.h +++ b/src/libs/qmldebug/basetoolsclient.h @@ -83,7 +83,7 @@ signals: void designModeBehaviorChanged(bool inDesignMode); void showAppOnTopChanged(bool showAppOnTop); void reloaded(); // the server has reloaded the document - void destroyedObject(); + void destroyedObject(int); void logActivity(QString client, QString message); diff --git a/src/libs/qmldebug/qmltoolsclient.cpp b/src/libs/qmldebug/qmltoolsclient.cpp index 44c3f9b5a5b..746569ca7be 100644 --- a/src/libs/qmldebug/qmltoolsclient.cpp +++ b/src/libs/qmldebug/qmltoolsclient.cpp @@ -35,10 +35,11 @@ //INSPECTOR SERVICE PROTOCOL //
//
: [] -// : {"enable", "disable", "select", "setAnimationSpeed", +// : {"enable", "disable", "select", "reload", "setAnimationSpeed", // "showAppOnTop", "createObject", "destroyObject", "moveObject", // "clearCache"} // : select: +// reload: > // setAnimationSpeed: // showAppOnTop: // createObject: @@ -88,8 +89,12 @@ void QmlToolsClient::messageReceived(const QByteArray &message) if ((m_reloadQueryId != -1) && (m_reloadQueryId == requestId) && success) emit reloaded(); - if ((m_destroyObjectQueryId != -1) && (m_destroyObjectQueryId == requestId) && success) - emit destroyedObject(); + if ((m_destroyObjectQueryId != -1) && (m_destroyObjectQueryId == requestId) + && success && !ds.atEnd()) { + int objectDebugId; + ds >> objectDebugId; + emit destroyedObject(objectDebugId); + } log(LogReceive, type, QString(QLatin1String("requestId: %1 success: %2")) .arg(QString::number(requestId)).arg(QString::number(success))); diff --git a/src/plugins/debugger/qml/qmlinspectoradapter.cpp b/src/plugins/debugger/qml/qmlinspectoradapter.cpp index 3c5b0144191..eb55367fc63 100644 --- a/src/plugins/debugger/qml/qmlinspectoradapter.cpp +++ b/src/plugins/debugger/qml/qmlinspectoradapter.cpp @@ -201,7 +201,7 @@ void QmlInspectorAdapter::toolsClientStatusChanged(QmlDebug::ClientStatus status connect(client, SIGNAL(logActivity(QString,QString)), m_debugAdapter, SLOT(logServiceActivity(QString,QString))); connect(client, SIGNAL(reloaded()), SLOT(onReloaded())); - connect(client, SIGNAL(destroyedObject()), SLOT(onDestroyedObject())); + connect(client, SIGNAL(destroyedObject(int)), SLOT(onDestroyedObject(int))); // only enable zoom action for Qt 4.x/old client // (zooming is integrated into selection tool in Qt 5). @@ -595,9 +595,9 @@ void QmlInspectorAdapter::onReloaded() } } -void QmlInspectorAdapter::onDestroyedObject() +void QmlInspectorAdapter::onDestroyedObject(int objectDebugId) { - m_agent->queryEngineContext(); + m_agent->fetchObject(m_agent->parentIdForObject(objectDebugId)); } } // namespace Internal diff --git a/src/plugins/debugger/qml/qmlinspectoradapter.h b/src/plugins/debugger/qml/qmlinspectoradapter.h index f8b282c7ef0..2e1f99b39fc 100644 --- a/src/plugins/debugger/qml/qmlinspectoradapter.h +++ b/src/plugins/debugger/qml/qmlinspectoradapter.h @@ -98,7 +98,7 @@ private slots: void onUpdateOnSaveChanged(const QVariant &value); void onReload(); void onReloaded(); - void onDestroyedObject(); + void onDestroyedObject(int); private: void setActiveEngineClient(QmlDebug::BaseEngineDebugClient *client); diff --git a/src/plugins/debugger/qml/qmlinspectoragent.cpp b/src/plugins/debugger/qml/qmlinspectoragent.cpp index 4afe525fd06..d3755c323be 100644 --- a/src/plugins/debugger/qml/qmlinspectoragent.cpp +++ b/src/plugins/debugger/qml/qmlinspectoragent.cpp @@ -254,6 +254,8 @@ QHash QmlInspectorAgent::rootObjectIds() const QHash rIds; foreach (const QByteArray &in, m_debugIdToIname) { const WatchData *data = m_debuggerEngine->watchHandler()->findData(in); + if (!data) + continue; int debugId = data->id; QString className = data->type; rIds.insert(debugId, className); @@ -467,6 +469,22 @@ void QmlInspectorAgent::reloadEngines() m_engineQueryId = m_engineClient->queryAvailableEngines(); } +int QmlInspectorAgent::parentIdForObject(int objectDebugId) +{ + int pid = -1; + + if (m_debugIdToIname.contains(objectDebugId)) { + QByteArray iname = m_debugIdToIname.value(objectDebugId); + if (iname.count('.') > 1) { + int offset = iname.lastIndexOf('.'); + QTC_ASSERT(offset > 0, return pid); + iname = iname.left(offset); + pid = m_debugIdToIname.key(iname); + } + } + return pid; +} + void QmlInspectorAgent::queryEngineContext() { if (debug) diff --git a/src/plugins/debugger/qml/qmlinspectoragent.h b/src/plugins/debugger/qml/qmlinspectoragent.h index 87f26f6a8ee..58659f8658e 100644 --- a/src/plugins/debugger/qml/qmlinspectoragent.h +++ b/src/plugins/debugger/qml/qmlinspectoragent.h @@ -89,6 +89,7 @@ public: void setEngineClient(QmlDebug::BaseEngineDebugClient *client); QString displayName(int objectDebugId) const; + int parentIdForObject(int objectDebugId); public slots: void fetchContextObjectsForLocation(const QString &file,