summaryrefslogtreecommitdiffstats
path: root/src/declarative/debugger/qdeclarativeenginedebugservice.cpp
diff options
context:
space:
mode:
authorAurindam Jana <aurindam.jana@digia.com>2012-09-28 15:01:08 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-01 08:27:13 +0100
commitad86cd24157cc6ded679f40807591981fe52d540 (patch)
treeceb5f99fc3e04bf22bdad2a00abb937311760289 /src/declarative/debugger/qdeclarativeenginedebugservice.cpp
parent646b60f0d3e45bcc240e5ad77a2700f4287c3162 (diff)
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: I7e3c9b9c321278dd24bd17ae2efdc690307cba8a Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/declarative/debugger/qdeclarativeenginedebugservice.cpp')
-rw-r--r--src/declarative/debugger/qdeclarativeenginedebugservice.cpp125
1 files changed, 64 insertions, 61 deletions
diff --git a/src/declarative/debugger/qdeclarativeenginedebugservice.cpp b/src/declarative/debugger/qdeclarativeenginedebugservice.cpp
index b5b46e3c..662fc0b6 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,
@@ -737,11 +739,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);
}