diff --git a/src/plugins/debugger/qml/qmlinspectoragent.cpp b/src/plugins/debugger/qml/qmlinspectoragent.cpp index 7e2aecc4697..4b1f557e107 100644 --- a/src/plugins/debugger/qml/qmlinspectoragent.cpp +++ b/src/plugins/debugger/qml/qmlinspectoragent.cpp @@ -661,12 +661,11 @@ void QmlInspectorAgent::insertObjectInTree(const ObjectReference &object) const int parentId = parentIdForIname(m_debugIdToIname.value(objectDebugId)); QElapsedTimer timeElapsed; - QList watchData; bool printTime = qmlInspectorLog().isDebugEnabled(); if (printTime) timeElapsed.start(); - watchData.append(buildWatchData(object, m_debugIdToIname.value(parentId), true)); + addWatchData(object, m_debugIdToIname.value(parentId), true); qCDebug(qmlInspectorLog) << __FUNCTION__ << "Time: Build Watch Data took " << timeElapsed.elapsed() << " ms"; if (printTime) @@ -675,10 +674,8 @@ void QmlInspectorAgent::insertObjectInTree(const ObjectReference &object) qCDebug(qmlInspectorLog) << __FUNCTION__ << "Time: Build Debug Id Hash took " << timeElapsed.elapsed() << " ms"; - WatchHandler *watchHandler = m_debuggerEngine->watchHandler(); if (printTime) timeElapsed.start(); - watchHandler->insertDataList(watchData); qCDebug(qmlInspectorLog) << __FUNCTION__ << "Time: Insertion took " << timeElapsed.elapsed() << " ms"; @@ -689,7 +686,7 @@ void QmlInspectorAgent::insertObjectInTree(const ObjectReference &object) // select item in view QByteArray iname = m_debugIdToIname.value(m_objectToSelect); qCDebug(qmlInspectorLog) << " selecting" << iname << "in tree"; - watchHandler->setCurrentItem(iname); + m_debuggerEngine->watchHandler()->setCurrentItem(iname); m_objectToSelect = -1; } } @@ -738,14 +735,12 @@ static QByteArray buildIName(const QByteArray &parentIname, const QString &name) return parentIname + "." + name.toLatin1(); } -QList QmlInspectorAgent::buildWatchData(const ObjectReference &obj, - const QByteArray &parentIname, - bool append) +void QmlInspectorAgent::addWatchData(const ObjectReference &obj, + const QByteArray &parentIname, + bool append) { qCDebug(qmlInspectorLog) << '(' << obj << parentIname << ')'; - QList list; - int objDebugId = obj.debugId(); QByteArray objIname = buildIName(parentIname, objDebugId); @@ -756,7 +751,7 @@ QList QmlInspectorAgent::buildWatchData(const ObjectReference &obj, name = obj.className(); if (name.isEmpty()) - return list; + return; // object objWatch.id = objDebugId; @@ -768,7 +763,7 @@ QList QmlInspectorAgent::buildWatchData(const ObjectReference &obj, objWatch.setHasChildren(true); objWatch.setAllUnneeded(); - list.append(objWatch); + m_debuggerEngine->watchHandler()->insertData(objWatch); addObjectWatch(objWatch.id); if (m_debugIdToIname.contains(objDebugId)) { // The data needs to be removed since we now know the parent and @@ -784,7 +779,7 @@ QList QmlInspectorAgent::buildWatchData(const ObjectReference &obj, // we don't know the children yet. Not adding the 'properties' // element makes sure we're queried on expansion. if (obj.needsMoreData()) - return list; + return; } // properties @@ -799,7 +794,7 @@ QList QmlInspectorAgent::buildWatchData(const ObjectReference &obj, propertiesWatch.setHasChildren(true); propertiesWatch.setAllUnneeded(); - list.append(propertiesWatch); + m_debuggerEngine->watchHandler()->insertData(propertiesWatch); foreach (const PropertyReference &property, obj.properties()) { const QString propertyName = property.name(); @@ -814,14 +809,13 @@ QList QmlInspectorAgent::buildWatchData(const ObjectReference &obj, propertyWatch.value = property.value().toString(); propertyWatch.setAllUnneeded(); propertyWatch.setHasChildren(false); - list.append(propertyWatch); + m_debuggerEngine->watchHandler()->insertData(propertyWatch); } } // recurse foreach (const ObjectReference &child, obj.children()) - list.append(buildWatchData(child, objIname, append)); - return list; + addWatchData(child, objIname, append); } void QmlInspectorAgent::log(QmlInspectorAgent::LogDirection direction, diff --git a/src/plugins/debugger/qml/qmlinspectoragent.h b/src/plugins/debugger/qml/qmlinspectoragent.h index 3c01307f150..b888161ae1f 100644 --- a/src/plugins/debugger/qml/qmlinspectoragent.h +++ b/src/plugins/debugger/qml/qmlinspectoragent.h @@ -113,8 +113,8 @@ private: void insertObjectInTree(const QmlDebug::ObjectReference &result); void buildDebugIdHashRecursive(const QmlDebug::ObjectReference &ref); - QList buildWatchData(const QmlDebug::ObjectReference &obj, - const QByteArray &parentIname, bool append); + void addWatchData(const QmlDebug::ObjectReference &obj, + const QByteArray &parentIname, bool append); enum LogDirection { LogSend, diff --git a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp index f2e5fd250e7..da87ce05f1c 100644 --- a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp +++ b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp @@ -1553,7 +1553,6 @@ void QmlV8DebuggerClient::updateScope(const QVariant &bodyVal, const QVariant &r QmlV8ObjectData objectData = extractData(bodyMap.value(_("object")), refsVal); QList handlesToLookup; - QList locals; foreach (const QVariant &property, objectData.properties) { QmlV8ObjectData localData = extractData(property, refsVal); WatchData data; @@ -1571,7 +1570,7 @@ void QmlV8DebuggerClient::updateScope(const QVariant &bodyVal, const QVariant &r data.type = localData.type; data.value = localData.value.toString(); data.setHasChildren(localData.properties.count()); - locals << data; + d->engine->watchHandler()->insertData(data); } else { handlesToLookup << handle; d->localsAndWatchers.insertMulti(handle, data.exp); @@ -1580,9 +1579,6 @@ void QmlV8DebuggerClient::updateScope(const QVariant &bodyVal, const QVariant &r if (!handlesToLookup.isEmpty()) d->lookup(handlesToLookup); - - if (!locals.isEmpty()) - d->engine->watchHandler()->insertDataList(locals); } QmlJS::ConsoleItem *constructLogItemTree(QmlJS::ConsoleItem *parent, @@ -1662,12 +1658,11 @@ void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success, QmlV8ObjectData body = extractData(bodyVal, refsVal); if (d->evaluatingExpression.contains(sequence)) { QString exp = d->evaluatingExpression.take(sequence); - QList watchDataList; WatchData data; //Do we have request to evaluate a local? if (exp.startsWith(QLatin1String("local."))) { const WatchData *watch = watchHandler->findData(exp.toLatin1()); - watchDataList << createWatchDataList(watch, body.properties, refsVal); + createWatchDataList(watch, body.properties, refsVal); } else { QByteArray iname = watchHandler->watcherName(exp.toLatin1()); SDEBUG(QString(iname)); @@ -1684,10 +1679,10 @@ void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success, //Do not set type since it is unknown data.setError(body.value.toString()); } - watchDataList << data << createWatchDataList(&data, body.properties, refsVal); + watchHandler->insertData(data); + createWatchDataList(&data, body.properties, refsVal); } //Insert the newly evaluated expression to the Watchers Window - watchHandler->insertDataList(watchDataList); } } } @@ -1704,7 +1699,6 @@ void QmlV8DebuggerClient::expandLocalsAndWatchers(const QVariant &bodyVal, const // } const QVariantMap body = bodyVal.toMap(); - QList watchDataList; QStringList handlesList = body.keys(); WatchHandler *watchHandler = d->engine->watchHandler(); foreach (const QString &handle, handlesList) { @@ -1713,10 +1707,10 @@ void QmlV8DebuggerClient::expandLocalsAndWatchers(const QVariant &bodyVal, const QByteArray prepend = d->localsAndWatchers.take(handle.toInt()); if (prepend.startsWith("local.") || prepend.startsWith("watch.")) { - //Data for expanded local/watch - //Could be an object or function + // Data for expanded local/watch. + // Could be an object or function. const WatchData *parent = watchHandler->findData(prepend); - watchDataList << createWatchDataList(parent, bodyObjectData.properties, refsVal); + createWatchDataList(parent, bodyObjectData.properties, refsVal); } else { //rest WatchData data; @@ -1730,20 +1724,17 @@ void QmlV8DebuggerClient::expandLocalsAndWatchers(const QVariant &bodyVal, const data.setHasChildren(bodyObjectData.properties.count()); - watchDataList << data; + d->engine->watchHandler()->insertData(data); } } - - watchHandler->insertDataList(watchDataList); } -QList QmlV8DebuggerClient::createWatchDataList(const WatchData *parent, +void QmlV8DebuggerClient::createWatchDataList(const WatchData *parent, const QVariantList &properties, const QVariant &refsVal) { - QList watchDataList; if (properties.count()) { - QTC_ASSERT(parent, return watchDataList); + QTC_ASSERT(parent, return); foreach (const QVariant &property, properties) { QmlV8ObjectData propertyData = extractData(property, refsVal); WatchData data; @@ -1766,10 +1757,9 @@ QList QmlV8DebuggerClient::createWatchDataList(const WatchData *paren data.type = propertyData.type; data.value = propertyData.value.toString(); data.setHasChildren(propertyData.properties.count()); - watchDataList << data; + d->engine->watchHandler()->insertData(data); } } - return watchDataList; } void QmlV8DebuggerClient::highlightExceptionCode(int lineNumber, diff --git a/src/plugins/debugger/qml/qmlv8debuggerclient.h b/src/plugins/debugger/qml/qmlv8debuggerclient.h index 524084a11f9..08df8d243ff 100644 --- a/src/plugins/debugger/qml/qmlv8debuggerclient.h +++ b/src/plugins/debugger/qml/qmlv8debuggerclient.h @@ -111,9 +111,9 @@ private: void updateEvaluationResult(int sequence, bool success, const QVariant &bodyVal, const QVariant &refsVal); void expandLocalsAndWatchers(const QVariant &bodyVal, const QVariant &refsVal); - QList createWatchDataList(const WatchData *parent, - const QVariantList &properties, - const QVariant &refsVal); + void createWatchDataList(const WatchData *parent, + const QVariantList &properties, + const QVariant &refsVal); void highlightExceptionCode(int lineNumber, const QString &filePath, const QString &errorMessage); diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 107d59fc05a..f42a96b7462 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -1253,12 +1253,6 @@ void WatchHandler::insertData(const WatchData &data) m_model->insertDataItem(data); } -void WatchHandler::insertDataList(const QList &list) -{ - for (int i = 0, n = list.size(); i != n; ++i) - m_model->insertDataItem(list.at(i)); -} - void WatchHandler::removeAllData(bool includeInspectData) { m_model->reinitialize(includeInspectData); diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index e99e449319d..c9d4dc6418e 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -239,7 +239,6 @@ public: void appendFormatRequests(DebuggerCommand *cmd); void insertData(const WatchData &data); // DEPRECATED - void insertDataList(const QList &list); // DEPRECATED void insertItem(WatchItem *item); // Takes ownership. void removeItemByIName(const QByteArray &iname); void removeAllData(bool includeInspectData = false);