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