diff options
author | Aurindam Jana <aurindam.jana@digia.com> | 2012-09-28 13:01:08 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-02 08:28:24 (GMT) |
commit | 32ea47c54efbe497927abb49fc4de54348d2db69 (patch) | |
tree | b21bbbdaf34ed48fa77c6fee9d02669820a3deea /src/declarative | |
parent | 4679c6901fc7c388fdf6c022d3499708222ef1f1 (diff) | |
download | Qt-32ea47c54efbe497927abb49fc4de54348d2db69.zip Qt-32ea47c54efbe497927abb49fc4de54348d2db69.tar.gz Qt-32ea47c54efbe497927abb49fc4de54348d2db69.tar.bz2 |
EngineDebug: Updated and renamed service
Updated service to include parent ids. Since this
will break client compatibility, the service
has been renamed to 'DeclarativeDebugger' from
'QDeclarativeEngine'. This is effectively a backport
of the 'QmlDebugger' service from Qt5.
Change-Id: Ic3000712d986e19bdf89417e9c4c23229d56f9dc
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/declarative')
4 files changed, 96 insertions, 72 deletions
diff --git a/src/declarative/debugger/qdeclarativeenginedebug.cpp b/src/declarative/debugger/qdeclarativeenginedebug.cpp index d2937ef..ebc3b0f 100644 --- a/src/declarative/debugger/qdeclarativeenginedebug.cpp +++ b/src/declarative/debugger/qdeclarativeenginedebug.cpp @@ -96,7 +96,7 @@ public: QDeclarativeEngineDebugClient::QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client, QDeclarativeEngineDebugPrivate *p) -: QDeclarativeDebugClient(QLatin1String("QDeclarativeEngine"), client), priv(p) +: QDeclarativeDebugClient(QLatin1String("DeclarativeDebugger"), client), priv(p) { } @@ -217,6 +217,8 @@ void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugOb o.m_source.m_lineNumber = data.lineNumber; o.m_source.m_columnNumber = data.columnNumber; o.m_contextDebugId = data.contextId; + o.m_parentId = data.parentId; + o.m_needsMoreData = simple; if (simple) return; @@ -246,6 +248,7 @@ void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugOb case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Basic: case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::List: case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::SignalProperty: + case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Variant: { prop.m_value = data.value; break; @@ -646,7 +649,8 @@ bool QDeclarativeEngineDebug::setBindingForObject(int objectDebugId, const QStri if (d->client->status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("SET_BINDING") << objectDebugId << propertyName << bindingExpression << isLiteralValue << source << line; + ds << QByteArray("SET_BINDING") << d->getId() << objectDebugId << propertyName << + bindingExpression << isLiteralValue << source << line; d->client->sendMessage(message); return true; } else { @@ -661,7 +665,7 @@ bool QDeclarativeEngineDebug::resetBindingForObject(int objectDebugId, const QSt if (d->client->status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("RESET_BINDING") << objectDebugId << propertyName; + ds << QByteArray("RESET_BINDING") << d->getId() << objectDebugId << propertyName; d->client->sendMessage(message); return true; } else { @@ -677,7 +681,8 @@ bool QDeclarativeEngineDebug::setMethodBody(int objectDebugId, const QString &me if (d->client->status() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { QByteArray message; QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("SET_METHOD_BODY") << objectDebugId << methodName << methodBody; + ds << QByteArray("SET_METHOD_BODY") << d->getId() << objectDebugId << methodName + << methodBody; d->client->sendMessage(message); return true; } else { @@ -866,27 +871,28 @@ QString QDeclarativeDebugEngineReference::name() const } QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference() -: m_debugId(-1), m_contextDebugId(-1) + : m_debugId(-1), m_parentId(-1), m_contextDebugId(-1), m_needsMoreData(false) { } QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(int debugId) -: m_debugId(debugId), m_contextDebugId(-1) +: m_debugId(debugId), m_parentId(-1), m_contextDebugId(-1), m_needsMoreData(false) { } QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &o) -: m_debugId(o.m_debugId), m_class(o.m_class), m_idString(o.m_idString), +: m_debugId(o.m_debugId), m_parentId(o.m_parentId), m_class(o.m_class), m_idString(o.m_idString), m_name(o.m_name), m_source(o.m_source), m_contextDebugId(o.m_contextDebugId), - m_properties(o.m_properties), m_children(o.m_children) + m_needsMoreData(o.m_needsMoreData), m_properties(o.m_properties), m_children(o.m_children) { } QDeclarativeDebugObjectReference & QDeclarativeDebugObjectReference::operator=(const QDeclarativeDebugObjectReference &o) { - m_debugId = o.m_debugId; m_class = o.m_class; m_idString = o.m_idString; - m_name = o.m_name; m_source = o.m_source; m_contextDebugId = o.m_contextDebugId; + m_debugId = o.m_debugId; m_parentId = o.m_parentId; m_class = o.m_class; + m_idString = o.m_idString; m_name = o.m_name; m_source = o.m_source; + m_contextDebugId = o.m_contextDebugId; m_needsMoreData = o.m_needsMoreData; m_properties = o.m_properties; m_children = o.m_children; return *this; } @@ -896,6 +902,11 @@ int QDeclarativeDebugObjectReference::debugId() const return m_debugId; } +int QDeclarativeDebugObjectReference::parentId() const +{ + return m_parentId; +} + QString QDeclarativeDebugObjectReference::className() const { return m_class; @@ -921,6 +932,11 @@ int QDeclarativeDebugObjectReference::contextDebugId() const return m_contextDebugId; } +bool QDeclarativeDebugObjectReference::needsMoreData() const +{ + return m_needsMoreData; +} + QList<QDeclarativeDebugPropertyReference> QDeclarativeDebugObjectReference::properties() const { return m_properties; diff --git a/src/declarative/debugger/qdeclarativeenginedebug_p.h b/src/declarative/debugger/qdeclarativeenginedebug_p.h index 5c8ff69..b5a8356 100644 --- a/src/declarative/debugger/qdeclarativeenginedebug_p.h +++ b/src/declarative/debugger/qdeclarativeenginedebug_p.h @@ -244,12 +244,14 @@ public: QDeclarativeDebugObjectReference &operator=(const QDeclarativeDebugObjectReference &); int debugId() const; + int parentId() const; QString className() const; QString idString() const; QString name() const; QDeclarativeDebugFileReference source() const; int contextDebugId() const; + bool needsMoreData() const; QList<QDeclarativeDebugPropertyReference> properties() const; QList<QDeclarativeDebugObjectReference> children() const; @@ -257,11 +259,13 @@ public: private: friend class QDeclarativeEngineDebugPrivate; int m_debugId; + int m_parentId; QString m_class; QString m_idString; QString m_name; QDeclarativeDebugFileReference m_source; int m_contextDebugId; + bool m_needsMoreData; QList<QDeclarativeDebugPropertyReference> m_properties; QList<QDeclarativeDebugObjectReference> m_children; }; diff --git a/src/declarative/debugger/qdeclarativeenginedebugservice.cpp b/src/declarative/debugger/qdeclarativeenginedebugservice.cpp index 95d74bd..486612a 100644 --- a/src/declarative/debugger/qdeclarativeenginedebugservice.cpp +++ b/src/declarative/debugger/qdeclarativeenginedebugservice.cpp @@ -67,7 +67,7 @@ QDeclarativeEngineDebugService *QDeclarativeEngineDebugService::instance() } QDeclarativeEngineDebugService::QDeclarativeEngineDebugService(QObject *parent) -: QDeclarativeDebugService(QLatin1String("QDeclarativeEngine"), parent), +: QDeclarativeDebugService(QLatin1String("DeclarativeDebugger"), parent), m_watch(new QDeclarativeWatcher(this)) { QObject::connect(m_watch, SIGNAL(propertyChanged(int,int,QMetaProperty,QVariant)), @@ -78,7 +78,8 @@ QDataStream &operator<<(QDataStream &ds, const QDeclarativeEngineDebugService::QDeclarativeObjectData &data) { ds << data.url << data.lineNumber << data.columnNumber << data.idString - << data.objectName << data.objectType << data.objectId << data.contextId; + << data.objectName << data.objectType << data.objectId << data.contextId + << data.parentId; return ds; } @@ -86,7 +87,8 @@ QDataStream &operator>>(QDataStream &ds, QDeclarativeEngineDebugService::QDeclarativeObjectData &data) { ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString - >> data.objectName >> data.objectType >> data.objectId >> data.contextId; + >> data.objectName >> data.objectType >> data.objectId >> data.contextId + >> data.parentId; return ds; } @@ -153,6 +155,8 @@ QDeclarativeEngineDebugService::propertyData(QObject *obj, int propIdx) rv.type = QDeclarativeObjectProperty::Object; } else if (QDeclarativeMetaType::isList(prop.userType())) { rv.type = QDeclarativeObjectProperty::List; + } else if (prop.userType() == QMetaType::QVariant) { + rv.type = QDeclarativeObjectProperty::Variant; } QVariant value; @@ -177,6 +181,16 @@ QVariant QDeclarativeEngineDebugService::valueContents(const QVariant &value) co return contents; } + if (value.type() == QVariant::Map) { + QVariantMap contents; + QMapIterator<QString, QVariant> i(value.toMap()); + while (i.hasNext()) { + i.next(); + contents.insert(i.key(), valueContents(i.value())); + } + return contents; + } + if (QDeclarativeValueTypeFactory::isValueType(userType)) return value; @@ -214,10 +228,31 @@ void QDeclarativeEngineDebugService::buildObjectDump(QDataStream &message, QObject *child = children.at(ii); if (qobject_cast<QDeclarativeContext*>(child)) continue; + if (!QDeclarativeBoundSignal::cast(child)) { + if (recur) + buildObjectDump(message, child, recur, dumpProperties); + else + message << objectData(child); + } + } + + if (!dumpProperties) { + message << 0; + return; + } + + QList<int> propertyIndexes; + for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) { + if (object->metaObject()->property(ii).isScriptable()) + propertyIndexes << ii; + } + + for (int ii = 0; ii < children.count(); ++ii) { + QObject *child = children.at(ii); + if (qobject_cast<QDeclarativeContext*>(child)) + continue; QDeclarativeBoundSignal *signal = QDeclarativeBoundSignal::cast(child); if (signal) { - if (!dumpProperties) - continue; QDeclarativeObjectProperty prop; prop.type = QDeclarativeObjectProperty::SignalProperty; prop.hasNotifySignal = false; @@ -236,25 +271,9 @@ void QDeclarativeEngineDebugService::buildObjectDump(QDataStream &message, } } fakeProperties << prop; - } else { - if (recur) - buildObjectDump(message, child, recur, dumpProperties); - else - message << objectData(child); } } - if (!dumpProperties) { - message << 0; - return; - } - - QList<int> propertyIndexes; - for (int ii = 0; ii < object->metaObject()->propertyCount(); ++ii) { - if (object->metaObject()->property(ii).isScriptable()) - propertyIndexes << ii; - } - message << propertyIndexes.size() + fakeProperties.count(); for (int ii = 0; ii < propertyIndexes.size(); ++ii) @@ -369,6 +388,7 @@ QDeclarativeEngineDebugService::objectData(QObject *object) rv.objectName = object->objectName(); rv.objectId = QDeclarativeDebugService::idForObject(object); rv.contextId = QDeclarativeDebugService::idForObject(qmlContext(object)); + rv.parentId = QDeclarativeDebugService::idForObject(object->parent()); QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject()); if (type) { @@ -389,15 +409,15 @@ void QDeclarativeEngineDebugService::messageReceived(const QByteArray &message) { QDataStream ds(message); + int queryId; QByteArray type; - ds >> type; + ds >> type >> queryId; + + QByteArray reply; + QDataStream rs(&reply, QIODevice::WriteOnly); if (type == "LIST_ENGINES") { - int queryId; - ds >> queryId; - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("LIST_ENGINES_R"); rs << queryId << m_engines.count(); @@ -406,21 +426,16 @@ void QDeclarativeEngineDebugService::messageReceived(const QByteArray &message) QString engineName = engine->objectName(); int engineId = QDeclarativeDebugService::idForObject(engine); - rs << engineName << engineId; } - sendMessage(reply); } else if (type == "LIST_OBJECTS") { - int queryId; int engineId = -1; - ds >> queryId >> engineId; + ds >> engineId; QDeclarativeEngine *engine = qobject_cast<QDeclarativeEngine *>(QDeclarativeDebugService::objectForId(engineId)); - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("LIST_OBJECTS_R") << queryId; if (engine) { @@ -428,19 +443,15 @@ void QDeclarativeEngineDebugService::messageReceived(const QByteArray &message) buildStatesList(engine->rootContext(), true); } - sendMessage(reply); } else if (type == "FETCH_OBJECT") { - int queryId; int objectId; bool recurse; bool dumpProperties = true; - ds >> queryId >> objectId >> recurse >> dumpProperties; + ds >> objectId >> recurse >> dumpProperties; QObject *object = QDeclarativeDebugService::objectForId(objectId); - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("FETCH_OBJECT_R") << queryId; if (object) { @@ -449,55 +460,40 @@ void QDeclarativeEngineDebugService::messageReceived(const QByteArray &message) buildObjectDump(rs, object, recurse, dumpProperties); } - sendMessage(reply); } else if (type == "WATCH_OBJECT") { - int queryId; int objectId; - ds >> queryId >> objectId; + ds >> objectId; bool ok = m_watch->addWatch(queryId, objectId); - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("WATCH_OBJECT_R") << queryId << ok; - sendMessage(reply); } else if (type == "WATCH_PROPERTY") { - int queryId; int objectId; QByteArray property; - ds >> queryId >> objectId >> property; + ds >> objectId >> property; bool ok = m_watch->addWatch(queryId, objectId, property); - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("WATCH_PROPERTY_R") << queryId << ok; - sendMessage(reply); } else if (type == "WATCH_EXPR_OBJECT") { - int queryId; int debugId; QString expr; - ds >> queryId >> debugId >> expr; + ds >> debugId >> expr; bool ok = m_watch->addWatch(queryId, debugId, expr); - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("WATCH_EXPR_OBJECT_R") << queryId << ok; - sendMessage(reply); + } else if (type == "NO_WATCH") { - int queryId; - ds >> queryId; m_watch->removeWatch(queryId); } else if (type == "EVAL_EXPRESSION") { - int queryId; int objectId; QString expr; - ds >> queryId >> objectId >> expr; + ds >> objectId >> expr; QObject *object = QDeclarativeDebugService::objectForId(objectId); QDeclarativeContext *context = qmlContext(object); @@ -514,11 +510,8 @@ void QDeclarativeEngineDebugService::messageReceived(const QByteArray &message) result = QLatin1String("<unknown context>"); } - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); rs << QByteArray("EVAL_EXPRESSION_R") << queryId << result; - sendMessage(reply); } else if (type == "SET_BINDING") { int objectId; QString propertyName; @@ -531,18 +524,27 @@ void QDeclarativeEngineDebugService::messageReceived(const QByteArray &message) ds >> filename >> line; } setBinding(objectId, propertyName, expr, isLiteralValue, filename, line); + + rs << QByteArray("SET_BINDING_R") << queryId; + } else if (type == "RESET_BINDING") { int objectId; QString propertyName; ds >> objectId >> propertyName; resetBinding(objectId, propertyName); + + rs << QByteArray("SET_BINDING_R") << queryId; + } else if (type == "SET_METHOD_BODY") { int objectId; QString methodName; QString methodBody; ds >> objectId >> methodName >> methodBody; setMethodBody(objectId, methodName, methodBody); + + rs << QByteArray("SET_BINDING_R") << queryId; } + sendMessage(reply); } void QDeclarativeEngineDebugService::setBinding(int objectId, @@ -736,11 +738,12 @@ void QDeclarativeEngineDebugService::objectCreated(QDeclarativeEngine *engine, Q int engineId = QDeclarativeDebugService::idForObject(engine); int objectId = QDeclarativeDebugService::idForObject(object); + int parentId = QDeclarativeDebugService::idForObject(object->parent()); QByteArray reply; QDataStream rs(&reply, QIODevice::WriteOnly); - rs << QByteArray("OBJECT_CREATED") << engineId << objectId; + rs << QByteArray("OBJECT_CREATED") << -1 << engineId << objectId << parentId; sendMessage(reply); } diff --git a/src/declarative/debugger/qdeclarativeenginedebugservice_p.h b/src/declarative/debugger/qdeclarativeenginedebugservice_p.h index e9facbb..d74b53d 100644 --- a/src/declarative/debugger/qdeclarativeenginedebugservice_p.h +++ b/src/declarative/debugger/qdeclarativeenginedebugservice_p.h @@ -82,10 +82,11 @@ public: QString objectType; int objectId; int contextId; + int parentId; }; struct QDeclarativeObjectProperty { - enum Type { Unknown, Basic, Object, List, SignalProperty }; + enum Type { Unknown, Basic, Object, List, SignalProperty, Variant }; Type type; QString name; QVariant value; |