forked from qt-creator/qt-creator
Debugger: Replace uses of one of the depracted WatchHandler members
Change-Id: I1761b75c0c2605e2d3157f318f26da5158cc6395 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -661,12 +661,11 @@ void QmlInspectorAgent::insertObjectInTree(const ObjectReference &object)
|
|||||||
const int parentId = parentIdForIname(m_debugIdToIname.value(objectDebugId));
|
const int parentId = parentIdForIname(m_debugIdToIname.value(objectDebugId));
|
||||||
|
|
||||||
QElapsedTimer timeElapsed;
|
QElapsedTimer timeElapsed;
|
||||||
QList<WatchData> watchData;
|
|
||||||
|
|
||||||
bool printTime = qmlInspectorLog().isDebugEnabled();
|
bool printTime = qmlInspectorLog().isDebugEnabled();
|
||||||
if (printTime)
|
if (printTime)
|
||||||
timeElapsed.start();
|
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 "
|
qCDebug(qmlInspectorLog) << __FUNCTION__ << "Time: Build Watch Data took "
|
||||||
<< timeElapsed.elapsed() << " ms";
|
<< timeElapsed.elapsed() << " ms";
|
||||||
if (printTime)
|
if (printTime)
|
||||||
@@ -675,10 +674,8 @@ void QmlInspectorAgent::insertObjectInTree(const ObjectReference &object)
|
|||||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << "Time: Build Debug Id Hash took "
|
qCDebug(qmlInspectorLog) << __FUNCTION__ << "Time: Build Debug Id Hash took "
|
||||||
<< timeElapsed.elapsed() << " ms";
|
<< timeElapsed.elapsed() << " ms";
|
||||||
|
|
||||||
WatchHandler *watchHandler = m_debuggerEngine->watchHandler();
|
|
||||||
if (printTime)
|
if (printTime)
|
||||||
timeElapsed.start();
|
timeElapsed.start();
|
||||||
watchHandler->insertDataList(watchData);
|
|
||||||
qCDebug(qmlInspectorLog) << __FUNCTION__ << "Time: Insertion took "
|
qCDebug(qmlInspectorLog) << __FUNCTION__ << "Time: Insertion took "
|
||||||
<< timeElapsed.elapsed() << " ms";
|
<< timeElapsed.elapsed() << " ms";
|
||||||
|
|
||||||
@@ -689,7 +686,7 @@ void QmlInspectorAgent::insertObjectInTree(const ObjectReference &object)
|
|||||||
// select item in view
|
// select item in view
|
||||||
QByteArray iname = m_debugIdToIname.value(m_objectToSelect);
|
QByteArray iname = m_debugIdToIname.value(m_objectToSelect);
|
||||||
qCDebug(qmlInspectorLog) << " selecting" << iname << "in tree";
|
qCDebug(qmlInspectorLog) << " selecting" << iname << "in tree";
|
||||||
watchHandler->setCurrentItem(iname);
|
m_debuggerEngine->watchHandler()->setCurrentItem(iname);
|
||||||
m_objectToSelect = -1;
|
m_objectToSelect = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -738,14 +735,12 @@ static QByteArray buildIName(const QByteArray &parentIname, const QString &name)
|
|||||||
return parentIname + "." + name.toLatin1();
|
return parentIname + "." + name.toLatin1();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<WatchData> QmlInspectorAgent::buildWatchData(const ObjectReference &obj,
|
void QmlInspectorAgent::addWatchData(const ObjectReference &obj,
|
||||||
const QByteArray &parentIname,
|
const QByteArray &parentIname,
|
||||||
bool append)
|
bool append)
|
||||||
{
|
{
|
||||||
qCDebug(qmlInspectorLog) << '(' << obj << parentIname << ')';
|
qCDebug(qmlInspectorLog) << '(' << obj << parentIname << ')';
|
||||||
|
|
||||||
QList<WatchData> list;
|
|
||||||
|
|
||||||
int objDebugId = obj.debugId();
|
int objDebugId = obj.debugId();
|
||||||
QByteArray objIname = buildIName(parentIname, objDebugId);
|
QByteArray objIname = buildIName(parentIname, objDebugId);
|
||||||
|
|
||||||
@@ -756,7 +751,7 @@ QList<WatchData> QmlInspectorAgent::buildWatchData(const ObjectReference &obj,
|
|||||||
name = obj.className();
|
name = obj.className();
|
||||||
|
|
||||||
if (name.isEmpty())
|
if (name.isEmpty())
|
||||||
return list;
|
return;
|
||||||
|
|
||||||
// object
|
// object
|
||||||
objWatch.id = objDebugId;
|
objWatch.id = objDebugId;
|
||||||
@@ -768,7 +763,7 @@ QList<WatchData> QmlInspectorAgent::buildWatchData(const ObjectReference &obj,
|
|||||||
objWatch.setHasChildren(true);
|
objWatch.setHasChildren(true);
|
||||||
objWatch.setAllUnneeded();
|
objWatch.setAllUnneeded();
|
||||||
|
|
||||||
list.append(objWatch);
|
m_debuggerEngine->watchHandler()->insertData(objWatch);
|
||||||
addObjectWatch(objWatch.id);
|
addObjectWatch(objWatch.id);
|
||||||
if (m_debugIdToIname.contains(objDebugId)) {
|
if (m_debugIdToIname.contains(objDebugId)) {
|
||||||
// The data needs to be removed since we now know the parent and
|
// 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'
|
// 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.
|
||||||
if (obj.needsMoreData())
|
if (obj.needsMoreData())
|
||||||
return list;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// properties
|
// properties
|
||||||
@@ -799,7 +794,7 @@ QList<WatchData> QmlInspectorAgent::buildWatchData(const ObjectReference &obj,
|
|||||||
propertiesWatch.setHasChildren(true);
|
propertiesWatch.setHasChildren(true);
|
||||||
propertiesWatch.setAllUnneeded();
|
propertiesWatch.setAllUnneeded();
|
||||||
|
|
||||||
list.append(propertiesWatch);
|
m_debuggerEngine->watchHandler()->insertData(propertiesWatch);
|
||||||
|
|
||||||
foreach (const PropertyReference &property, obj.properties()) {
|
foreach (const PropertyReference &property, obj.properties()) {
|
||||||
const QString propertyName = property.name();
|
const QString propertyName = property.name();
|
||||||
@@ -814,14 +809,13 @@ QList<WatchData> QmlInspectorAgent::buildWatchData(const ObjectReference &obj,
|
|||||||
propertyWatch.value = property.value().toString();
|
propertyWatch.value = property.value().toString();
|
||||||
propertyWatch.setAllUnneeded();
|
propertyWatch.setAllUnneeded();
|
||||||
propertyWatch.setHasChildren(false);
|
propertyWatch.setHasChildren(false);
|
||||||
list.append(propertyWatch);
|
m_debuggerEngine->watchHandler()->insertData(propertyWatch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// recurse
|
// recurse
|
||||||
foreach (const ObjectReference &child, obj.children())
|
foreach (const ObjectReference &child, obj.children())
|
||||||
list.append(buildWatchData(child, objIname, append));
|
addWatchData(child, objIname, append);
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlInspectorAgent::log(QmlInspectorAgent::LogDirection direction,
|
void QmlInspectorAgent::log(QmlInspectorAgent::LogDirection direction,
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ private:
|
|||||||
void insertObjectInTree(const QmlDebug::ObjectReference &result);
|
void insertObjectInTree(const QmlDebug::ObjectReference &result);
|
||||||
|
|
||||||
void buildDebugIdHashRecursive(const QmlDebug::ObjectReference &ref);
|
void buildDebugIdHashRecursive(const QmlDebug::ObjectReference &ref);
|
||||||
QList<WatchData> buildWatchData(const QmlDebug::ObjectReference &obj,
|
void addWatchData(const QmlDebug::ObjectReference &obj,
|
||||||
const QByteArray &parentIname, bool append);
|
const QByteArray &parentIname, bool append);
|
||||||
|
|
||||||
enum LogDirection {
|
enum LogDirection {
|
||||||
|
|||||||
@@ -1553,7 +1553,6 @@ void QmlV8DebuggerClient::updateScope(const QVariant &bodyVal, const QVariant &r
|
|||||||
QmlV8ObjectData objectData = extractData(bodyMap.value(_("object")), refsVal);
|
QmlV8ObjectData objectData = extractData(bodyMap.value(_("object")), refsVal);
|
||||||
|
|
||||||
QList<int> handlesToLookup;
|
QList<int> handlesToLookup;
|
||||||
QList<WatchData> locals;
|
|
||||||
foreach (const QVariant &property, objectData.properties) {
|
foreach (const QVariant &property, objectData.properties) {
|
||||||
QmlV8ObjectData localData = extractData(property, refsVal);
|
QmlV8ObjectData localData = extractData(property, refsVal);
|
||||||
WatchData data;
|
WatchData data;
|
||||||
@@ -1571,7 +1570,7 @@ void QmlV8DebuggerClient::updateScope(const QVariant &bodyVal, const QVariant &r
|
|||||||
data.type = localData.type;
|
data.type = localData.type;
|
||||||
data.value = localData.value.toString();
|
data.value = localData.value.toString();
|
||||||
data.setHasChildren(localData.properties.count());
|
data.setHasChildren(localData.properties.count());
|
||||||
locals << data;
|
d->engine->watchHandler()->insertData(data);
|
||||||
} else {
|
} else {
|
||||||
handlesToLookup << handle;
|
handlesToLookup << handle;
|
||||||
d->localsAndWatchers.insertMulti(handle, data.exp);
|
d->localsAndWatchers.insertMulti(handle, data.exp);
|
||||||
@@ -1580,9 +1579,6 @@ void QmlV8DebuggerClient::updateScope(const QVariant &bodyVal, const QVariant &r
|
|||||||
|
|
||||||
if (!handlesToLookup.isEmpty())
|
if (!handlesToLookup.isEmpty())
|
||||||
d->lookup(handlesToLookup);
|
d->lookup(handlesToLookup);
|
||||||
|
|
||||||
if (!locals.isEmpty())
|
|
||||||
d->engine->watchHandler()->insertDataList(locals);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJS::ConsoleItem *constructLogItemTree(QmlJS::ConsoleItem *parent,
|
QmlJS::ConsoleItem *constructLogItemTree(QmlJS::ConsoleItem *parent,
|
||||||
@@ -1662,12 +1658,11 @@ void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success,
|
|||||||
QmlV8ObjectData body = extractData(bodyVal, refsVal);
|
QmlV8ObjectData body = extractData(bodyVal, refsVal);
|
||||||
if (d->evaluatingExpression.contains(sequence)) {
|
if (d->evaluatingExpression.contains(sequence)) {
|
||||||
QString exp = d->evaluatingExpression.take(sequence);
|
QString exp = d->evaluatingExpression.take(sequence);
|
||||||
QList<WatchData> watchDataList;
|
|
||||||
WatchData data;
|
WatchData data;
|
||||||
//Do we have request to evaluate a local?
|
//Do we have request to evaluate a local?
|
||||||
if (exp.startsWith(QLatin1String("local."))) {
|
if (exp.startsWith(QLatin1String("local."))) {
|
||||||
const WatchData *watch = watchHandler->findData(exp.toLatin1());
|
const WatchData *watch = watchHandler->findData(exp.toLatin1());
|
||||||
watchDataList << createWatchDataList(watch, body.properties, refsVal);
|
createWatchDataList(watch, body.properties, refsVal);
|
||||||
} else {
|
} else {
|
||||||
QByteArray iname = watchHandler->watcherName(exp.toLatin1());
|
QByteArray iname = watchHandler->watcherName(exp.toLatin1());
|
||||||
SDEBUG(QString(iname));
|
SDEBUG(QString(iname));
|
||||||
@@ -1684,10 +1679,10 @@ void QmlV8DebuggerClient::updateEvaluationResult(int sequence, bool success,
|
|||||||
//Do not set type since it is unknown
|
//Do not set type since it is unknown
|
||||||
data.setError(body.value.toString());
|
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
|
//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();
|
const QVariantMap body = bodyVal.toMap();
|
||||||
|
|
||||||
QList<WatchData> watchDataList;
|
|
||||||
QStringList handlesList = body.keys();
|
QStringList handlesList = body.keys();
|
||||||
WatchHandler *watchHandler = d->engine->watchHandler();
|
WatchHandler *watchHandler = d->engine->watchHandler();
|
||||||
foreach (const QString &handle, handlesList) {
|
foreach (const QString &handle, handlesList) {
|
||||||
@@ -1713,10 +1707,10 @@ void QmlV8DebuggerClient::expandLocalsAndWatchers(const QVariant &bodyVal, const
|
|||||||
QByteArray prepend = d->localsAndWatchers.take(handle.toInt());
|
QByteArray prepend = d->localsAndWatchers.take(handle.toInt());
|
||||||
|
|
||||||
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 = watchHandler->findData(prepend);
|
const WatchData *parent = watchHandler->findData(prepend);
|
||||||
watchDataList << createWatchDataList(parent, bodyObjectData.properties, refsVal);
|
createWatchDataList(parent, bodyObjectData.properties, refsVal);
|
||||||
} else {
|
} else {
|
||||||
//rest
|
//rest
|
||||||
WatchData data;
|
WatchData data;
|
||||||
@@ -1730,20 +1724,17 @@ void QmlV8DebuggerClient::expandLocalsAndWatchers(const QVariant &bodyVal, const
|
|||||||
|
|
||||||
data.setHasChildren(bodyObjectData.properties.count());
|
data.setHasChildren(bodyObjectData.properties.count());
|
||||||
|
|
||||||
watchDataList << data;
|
d->engine->watchHandler()->insertData(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watchHandler->insertDataList(watchDataList);
|
void QmlV8DebuggerClient::createWatchDataList(const WatchData *parent,
|
||||||
}
|
|
||||||
|
|
||||||
QList<WatchData> QmlV8DebuggerClient::createWatchDataList(const WatchData *parent,
|
|
||||||
const QVariantList &properties,
|
const QVariantList &properties,
|
||||||
const QVariant &refsVal)
|
const QVariant &refsVal)
|
||||||
{
|
{
|
||||||
QList<WatchData> watchDataList;
|
|
||||||
if (properties.count()) {
|
if (properties.count()) {
|
||||||
QTC_ASSERT(parent, return watchDataList);
|
QTC_ASSERT(parent, return);
|
||||||
foreach (const QVariant &property, properties) {
|
foreach (const QVariant &property, properties) {
|
||||||
QmlV8ObjectData propertyData = extractData(property, refsVal);
|
QmlV8ObjectData propertyData = extractData(property, refsVal);
|
||||||
WatchData data;
|
WatchData data;
|
||||||
@@ -1766,10 +1757,9 @@ QList<WatchData> QmlV8DebuggerClient::createWatchDataList(const WatchData *paren
|
|||||||
data.type = propertyData.type;
|
data.type = propertyData.type;
|
||||||
data.value = propertyData.value.toString();
|
data.value = propertyData.value.toString();
|
||||||
data.setHasChildren(propertyData.properties.count());
|
data.setHasChildren(propertyData.properties.count());
|
||||||
watchDataList << data;
|
d->engine->watchHandler()->insertData(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return watchDataList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlV8DebuggerClient::highlightExceptionCode(int lineNumber,
|
void QmlV8DebuggerClient::highlightExceptionCode(int lineNumber,
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ private:
|
|||||||
void updateEvaluationResult(int sequence, bool success, const QVariant &bodyVal,
|
void updateEvaluationResult(int sequence, bool success, const QVariant &bodyVal,
|
||||||
const QVariant &refsVal);
|
const QVariant &refsVal);
|
||||||
void expandLocalsAndWatchers(const QVariant &bodyVal, const QVariant &refsVal);
|
void expandLocalsAndWatchers(const QVariant &bodyVal, const QVariant &refsVal);
|
||||||
QList<WatchData> createWatchDataList(const WatchData *parent,
|
void createWatchDataList(const WatchData *parent,
|
||||||
const QVariantList &properties,
|
const QVariantList &properties,
|
||||||
const QVariant &refsVal);
|
const QVariant &refsVal);
|
||||||
|
|
||||||
|
|||||||
@@ -1253,12 +1253,6 @@ void WatchHandler::insertData(const WatchData &data)
|
|||||||
m_model->insertDataItem(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)
|
void WatchHandler::removeAllData(bool includeInspectData)
|
||||||
{
|
{
|
||||||
m_model->reinitialize(includeInspectData);
|
m_model->reinitialize(includeInspectData);
|
||||||
|
|||||||
@@ -239,7 +239,6 @@ public:
|
|||||||
void appendFormatRequests(DebuggerCommand *cmd);
|
void appendFormatRequests(DebuggerCommand *cmd);
|
||||||
|
|
||||||
void insertData(const WatchData &data); // DEPRECATED
|
void insertData(const WatchData &data); // DEPRECATED
|
||||||
void insertDataList(const QList<WatchData> &list); // DEPRECATED
|
|
||||||
void insertItem(WatchItem *item); // Takes ownership.
|
void insertItem(WatchItem *item); // Takes ownership.
|
||||||
void removeItemByIName(const QByteArray &iname);
|
void removeItemByIName(const QByteArray &iname);
|
||||||
void removeAllData(bool includeInspectData = false);
|
void removeAllData(bool includeInspectData = false);
|
||||||
|
|||||||
Reference in New Issue
Block a user