Commit bd5fe524 authored by Simjees Abraham's avatar Simjees Abraham Committed by Aurindam Jana

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: default avatarAurindam Jana <aurindam.jana@nokia.com>
parent 30a6beae
......@@ -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);
......
......@@ -35,10 +35,11 @@
//INSPECTOR SERVICE PROTOCOL
// <HEADER><COMMAND><DATA>
// <HEADER> : <type{request, response, event}><requestId/eventId>[<response_success_bool>]
// <COMMAND> : {"enable", "disable", "select", "setAnimationSpeed",
// <COMMAND> : {"enable", "disable", "select", "reload", "setAnimationSpeed",
// "showAppOnTop", "createObject", "destroyObject", "moveObject",
// "clearCache"}
// <DATA> : select: <debugIds_int_list>
// reload: <hash<changed_filename_string, filecontents_bytearray>>
// setAnimationSpeed: <speed_real>
// showAppOnTop: <set_bool>
// createObject: <qml_string><parentId_int><imports_string_list><filename_string>
......@@ -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)));
......
......@@ -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
......
......@@ -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);
......
......@@ -254,6 +254,8 @@ QHash<int,QString> QmlInspectorAgent::rootObjectIds() const
QHash<int,QString> 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)
......
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment