Commit 45540a30 authored by Aurindam Jana's avatar Aurindam Jana Committed by hjk
Browse files

QmlDebugging: Save few cycles



Change-Id: I6d094605e3983128b844f2156909b98a4016509f
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 3a3433f7
......@@ -228,9 +228,10 @@ ObjectReference QmlInspectorAgent::objectForName(
{
if (!objectId.isEmpty() && objectId[0].isLower()) {
QHashIterator<int, QByteArray> iter(m_debugIdToIname);
const WatchHandler *watchHandler = m_debuggerEngine->watchHandler();
while (iter.hasNext()) {
iter.next();
const WatchData *wd = m_debuggerEngine->watchHandler()->findData(iter.value());
const WatchData *wd = watchHandler->findData(iter.value());
if (wd && wd->name == objectId)
return ObjectReference(iter.key());
}
......@@ -286,8 +287,9 @@ int QmlInspectorAgent::objectIdForLocation(
QHash<int,QString> QmlInspectorAgent::rootObjectIds() const
{
QHash<int,QString> rIds;
const WatchHandler *watchHandler = m_debuggerEngine->watchHandler();
foreach (const QByteArray &in, m_debugIdToIname) {
const WatchData *data = m_debuggerEngine->watchHandler()->findData(in);
const WatchData *data = watchHandler->findData(in);
if (!data)
continue;
int debugId = data->id;
......@@ -482,13 +484,14 @@ void QmlInspectorAgent::onValueChanged(int debugId, const QByteArray &propertyNa
{
const QByteArray iname = m_debugIdToIname.value(debugId) +
".[properties]." + propertyName;
const WatchData *data = m_debuggerEngine->watchHandler()->findData(iname);
WatchHandler *watchHandler = m_debuggerEngine->watchHandler();
const WatchData *data = watchHandler->findData(iname);
if (debug)
qDebug() << __FUNCTION__ << "(" << debugId << ")" << iname <<value.toString();
if (data) {
WatchData d(*data);
d.value = value.toString();
m_debuggerEngine->watchHandler()->insertData(d);
watchHandler->insertData(d);
}
}
......@@ -673,9 +676,10 @@ void QmlInspectorAgent::objectTreeFetched(const ObjectReference &object)
m_newObjectsCreated = false;
m_objectStack.clear();
WatchHandler *watchHandler = m_debuggerEngine->watchHandler();
if (debug)
timeElapsed.start();
m_debuggerEngine->watchHandler()->insertData(watchData);
watchHandler->insertData(watchData);
if (debug)
qDebug() << __FUNCTION__ << "Time: Insertion took " << timeElapsed.elapsed() << " ms";
......@@ -687,7 +691,7 @@ void QmlInspectorAgent::objectTreeFetched(const ObjectReference &object)
QByteArray iname = m_debugIdToIname.value(last.debugId());
if (debug)
qDebug() << " selecting" << iname << "in tree";
m_debuggerEngine->watchHandler()->setCurrentItem(iname);
watchHandler->setCurrentItem(iname);
m_objectToSelect = -1;
}
}
......@@ -783,16 +787,16 @@ QList<WatchData> QmlInspectorAgent::buildWatchData(const ObjectReference &obj,
addObjectWatch(objWatch.id);
}
// To improve performance, we do not insert data for items
// that have not been previously queried when the object tree is refreshed.
if (!m_debuggerEngine->watchHandler()->isExpandedIName(objIname) && m_newObjectsCreated)
append = false;
if (!m_debuggerEngine->watchHandler()->isExpandedIName(objIname)
&& obj.needsMoreData()) {
if (!m_debuggerEngine->watchHandler()->isExpandedIName(objIname)) {
// we don't know the children yet. Not adding the 'properties'
// element makes sure we're queried on expansion.
return list;
if (obj.needsMoreData())
return list;
// To improve performance, we do not insert data for items
// that have not been previously queried when the object tree is refreshed.
if (m_newObjectsCreated)
append = false;
}
// properties
......
......@@ -1798,6 +1798,7 @@ void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success, con
// "running" : <is the VM running after sending this response>
// "success" : true
// }
WatchHandler *watchHandler = d->engine->watchHandler();
if (d->updateLocalsAndWatchers.contains(sequence)) {
d->updateLocalsAndWatchers.removeOne(sequence);
//Update the locals
......@@ -1805,7 +1806,7 @@ void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success, con
d->scope(index);
//Also update "this"
QByteArray iname("local.this");
const WatchData *parent = d->engine->watchHandler()->findData(iname);
const WatchData *parent = watchHandler->findData(iname);
d->localsAndWatchers.insertMulti(parent->id, iname);
d->lookup(QList<int>() << parent->id);
......@@ -1828,10 +1829,10 @@ void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success, con
WatchData data;
//Do we have request to evaluate a local?
if (exp.startsWith("local.")) {
const WatchData *watch = d->engine->watchHandler()->findData(exp.toLatin1());
const WatchData *watch = watchHandler->findData(exp.toLatin1());
watchDataList << createWatchDataList(watch, body.properties, refsVal);
} else {
QByteArray iname = d->engine->watchHandler()->watcherName(exp.toLatin1());
QByteArray iname = watchHandler->watcherName(exp.toLatin1());
SDEBUG(QString(iname));
data.exp = exp.toLatin1();
......@@ -1849,7 +1850,7 @@ void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success, con
watchDataList << data << createWatchDataList(&data, body.properties, refsVal);
}
//Insert the newly evaluated expression to the Watchers Window
d->engine->watchHandler()->insertData(watchDataList);
watchHandler->insertData(watchDataList);
}
}
}
......@@ -1918,6 +1919,7 @@ void QmlV8DebuggerClient::expandLocalsAndWatchers(const QVariant &bodyVal, const
QList<WatchData> watchDataList;
QStringList handlesList = body.keys();
WatchHandler *watchHandler = d->engine->watchHandler();
foreach (const QString &handle, handlesList) {
QmlV8ObjectData bodyObjectData = d->extractData(
body.value(handle), refsVal);
......@@ -1926,7 +1928,7 @@ void QmlV8DebuggerClient::expandLocalsAndWatchers(const QVariant &bodyVal, const
if (prepend.startsWith("local.") || prepend.startsWith("watch.")) {
//Data for expanded local/watch
//Could be an object or function
const WatchData *parent = d->engine->watchHandler()->findData(prepend);
const WatchData *parent = watchHandler->findData(prepend);
watchDataList << createWatchDataList(parent, bodyObjectData.properties, refsVal);
} else {
//rest
......@@ -1945,7 +1947,7 @@ void QmlV8DebuggerClient::expandLocalsAndWatchers(const QVariant &bodyVal, const
}
}
d->engine->watchHandler()->insertData(watchDataList);
watchHandler->insertData(watchDataList);
}
QList<WatchData> QmlV8DebuggerClient::createWatchDataList(const WatchData *parent,
......
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