Commit 3fd6e9e7 authored by hjk's avatar hjk

Debugger: Replace uses of one of the depracted WatchHandler members

Change-Id: I1761b75c0c2605e2d3157f318f26da5158cc6395
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 3594d689
......@@ -661,12 +661,11 @@ void QmlInspectorAgent::insertObjectInTree(const ObjectReference &object)
const int parentId = parentIdForIname(m_debugIdToIname.value(objectDebugId));
QElapsedTimer timeElapsed;
QList<WatchData> 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<WatchData> 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<WatchData> list;
int objDebugId = obj.debugId();
QByteArray objIname = buildIName(parentIname, objDebugId);
......@@ -756,7 +751,7 @@ QList<WatchData> QmlInspectorAgent::buildWatchData(const ObjectReference &obj,
name = obj.className();
if (name.isEmpty())
return list;
return;
// object
objWatch.id = objDebugId;
......@@ -768,7 +763,7 @@ QList<WatchData> 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<WatchData> 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<WatchData> 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<WatchData> 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,
......
......@@ -113,8 +113,8 @@ private:
void insertObjectInTree(const QmlDebug::ObjectReference &result);
void buildDebugIdHashRecursive(const QmlDebug::ObjectReference &ref);
QList<WatchData> buildWatchData(const QmlDebug::ObjectReference &obj,
const QByteArray &parentIname, bool append);
void addWatchData(const QmlDebug::ObjectReference &obj,
const QByteArray &parentIname, bool append);
enum LogDirection {
LogSend,
......
......@@ -1553,7 +1553,6 @@ void QmlV8DebuggerClient::updateScope(const QVariant &bodyVal, const QVariant &r
QmlV8ObjectData objectData = extractData(bodyMap.value(_("object")), refsVal);
QList<int> handlesToLookup;
QList<WatchData> 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<WatchData> 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<WatchData> 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<WatchData> QmlV8DebuggerClient::createWatchDataList(const WatchData *parent,
void QmlV8DebuggerClient::createWatchDataList(const WatchData *parent,
const QVariantList &properties,
const QVariant &refsVal)
{
QList<WatchData> 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<WatchData> 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,
......
......@@ -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<WatchData> 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);
......
......@@ -1253,12 +1253,6 @@ void WatchHandler::insertData(const WatchData &data)
m_model->insertDataItem(data);
}
void WatchHandler::insertDataList(const QList<WatchData> &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);
......
......@@ -239,7 +239,6 @@ public:
void appendFormatRequests(DebuggerCommand *cmd);
void insertData(const WatchData &data); // DEPRECATED
void insertDataList(const QList<WatchData> &list); // DEPRECATED
void insertItem(WatchItem *item); // Takes ownership.
void removeItemByIName(const QByteArray &iname);
void removeAllData(bool includeInspectData = false);
......
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