summaryrefslogtreecommitdiffstats
path: root/src/declarative/debugger
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/debugger')
-rw-r--r--src/declarative/debugger/qmldebug.cpp205
-rw-r--r--src/declarative/debugger/qmldebug.h59
-rw-r--r--src/declarative/debugger/qmldebugservice.h2
3 files changed, 244 insertions, 22 deletions
diff --git a/src/declarative/debugger/qmldebug.cpp b/src/declarative/debugger/qmldebug.cpp
index 57e5858..7483fe2 100644
--- a/src/declarative/debugger/qmldebug.cpp
+++ b/src/declarative/debugger/qmldebug.cpp
@@ -36,6 +36,8 @@ public:
QHash<int, QmlDebugEnginesQuery *> enginesQuery;
QHash<int, QmlDebugRootContextQuery *> rootContextQuery;
QHash<int, QmlDebugObjectQuery *> objectQuery;
+
+ QHash<int, QmlDebugWatch *> watched;
};
QmlEngineDebugClient::QmlEngineDebugClient(QmlDebugConnection *client,
@@ -91,6 +93,7 @@ void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugObjectReference &o,
o.m_source.m_url = data.url;
o.m_source.m_lineNumber = data.lineNumber;
o.m_source.m_columnNumber = data.columnNumber;
+ o.m_contextDebugId = data.contextId;
if (simple)
return;
@@ -104,6 +107,7 @@ void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugObjectReference &o,
QmlDebugPropertyReference prop;
prop.m_name = data.name;
prop.m_binding = data.binding;
+ prop.m_objectDebugId = o.m_debugId;
if (data.type == QmlEngineDebugServer::QmlObjectProperty::Basic)
prop.m_value = data.value;
else if (data.type == QmlEngineDebugServer::QmlObjectProperty::Object) {
@@ -144,6 +148,7 @@ void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugContextReference &c)
QmlDebugObjectReference obj;
decode(ds, obj, true);
+ obj.m_contextDebugId = c.m_debugId;
c.m_objects << obj;
}
}
@@ -155,6 +160,8 @@ void QmlEngineDebugPrivate::message(const QByteArray &data)
QByteArray type;
ds >> type;
+ //qDebug() << "QmlEngineDebugPrivate::message()" << type;
+
if (type == "LIST_ENGINES_R") {
int queryId;
ds >> queryId;
@@ -204,6 +211,47 @@ void QmlEngineDebugPrivate::message(const QByteArray &data)
query->m_client = 0;
query->setState(QmlDebugQuery::Completed);
+ } else if (type == "WATCH_PROPERTY_R") {
+ int queryId;
+ bool ok;
+ ds >> queryId >> ok;
+
+ QmlDebugWatch *watch = watched.value(queryId);
+ if (!watch)
+ return;
+
+ watch->setState(ok ? QmlDebugWatch::Active : QmlDebugWatch::Inactive);
+ } else if (type == "WATCH_OBJECT_R") {
+ int queryId;
+ bool ok;
+ ds >> queryId >> ok;
+
+ QmlDebugWatch *watch = watched.value(queryId);
+ if (!watch)
+ return;
+
+ watch->setState(ok ? QmlDebugWatch::Active : QmlDebugWatch::Inactive);
+ } else if (type == "WATCH_EXPR_OBJECT_R") {
+ int queryId;
+ bool ok;
+ ds >> queryId >> ok;
+
+ QmlDebugWatch *watch = watched.value(queryId);
+ if (!watch)
+ return;
+
+ watch->setState(ok ? QmlDebugWatch::Active : QmlDebugWatch::Inactive);
+ } else if (type == "UPDATE_WATCH") {
+ int queryId;
+ int debugId;
+ QByteArray name;
+ QVariant value;
+ ds >> queryId >> debugId >> name >> value;
+
+ QmlDebugWatch *watch = watched.value(queryId);
+ if (!watch)
+ return;
+ emit watch->valueChanged(name, value);
}
}
@@ -212,10 +260,27 @@ QmlEngineDebug::QmlEngineDebug(QmlDebugConnection *client, QObject *parent)
{
}
-QmlDebugWatch *QmlEngineDebug::addWatch(const QmlDebugPropertyReference &, QObject *)
+QmlDebugPropertyWatch *QmlEngineDebug::addWatch(const QmlDebugPropertyReference &property, QObject *parent)
{
- qWarning("QmlEngineDebug::addWatch(): Not implemented");
- return 0;
+ Q_D(QmlEngineDebug);
+
+ QmlDebugPropertyWatch *watch = new QmlDebugPropertyWatch(parent);
+ if (d->client->isConnected()) {
+ //query->m_client = this;
+ int queryId = d->getId();
+ watch->m_queryId = queryId;
+ watch->m_objectDebugId = property.objectDebugId();
+ d->watched.insert(queryId, watch);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("WATCH_PROPERTY") << queryId << property.objectDebugId() << property.name().toLatin1();
+ d->client->sendMessage(message);
+ } else {
+ watch->m_state = QmlDebugWatch::Dead;
+ }
+
+ return watch;
}
QmlDebugWatch *QmlEngineDebug::addWatch(const QmlDebugContextReference &, const QString &, QObject *)
@@ -224,16 +289,46 @@ QmlDebugWatch *QmlEngineDebug::addWatch(const QmlDebugContextReference &, const
return 0;
}
-QmlDebugWatch *QmlEngineDebug::addWatch(const QmlDebugObjectReference &, const QString &, QObject *)
+QmlDebugObjectExpressionWatch *QmlEngineDebug::addWatch(const QmlDebugObjectReference &object, const QString &expr, QObject *parent)
{
- qWarning("QmlEngineDebug::addWatch(): Not implemented");
- return 0;
+ Q_D(QmlEngineDebug);
+ QmlDebugObjectExpressionWatch *watch = new QmlDebugObjectExpressionWatch(parent);
+ if (d->client->isConnected()) {
+ int queryId = d->getId();
+ watch->m_queryId = queryId;
+ watch->m_objectDebugId = object.debugId();
+ d->watched.insert(queryId, watch);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("WATCH_EXPR_OBJECT") << queryId << object.debugId() << expr;
+ d->client->sendMessage(message);
+ } else {
+ watch->m_state = QmlDebugWatch::Dead;
+ }
+ return watch;
}
-QmlDebugWatch *QmlEngineDebug::addWatch(const QmlDebugObjectReference &, QObject *)
+QmlDebugWatch *QmlEngineDebug::addWatch(const QmlDebugObjectReference &object, QObject *parent)
{
- qWarning("QmlEngineDebug::addWatch(): Not implemented");
- return 0;
+ Q_D(QmlEngineDebug);
+
+ QmlDebugWatch *watch = new QmlDebugWatch(parent);
+ if (d->client->isConnected()) {
+ int queryId = d->getId();
+ watch->m_queryId = queryId;
+ watch->m_objectDebugId = object.debugId();
+ d->watched.insert(queryId, watch);
+
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("WATCH_OBJECT") << queryId << object.debugId();
+ d->client->sendMessage(message);
+ } else {
+ watch->m_state = QmlDebugWatch::Dead;
+ }
+
+ return watch;
}
QmlDebugWatch *QmlEngineDebug::addWatch(const QmlDebugFileReference &, QObject *)
@@ -242,6 +337,20 @@ QmlDebugWatch *QmlEngineDebug::addWatch(const QmlDebugFileReference &, QObject *
return 0;
}
+void QmlEngineDebug::removeWatch(QmlDebugWatch *watch)
+{
+ Q_D(QmlEngineDebug);
+
+ d->watched.remove(watch->queryId());
+
+ if (d->client->isConnected()) {
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("NO_WATCH") << watch->queryId();
+ d->client->sendMessage(message);
+ }
+}
+
QmlDebugEnginesQuery *QmlEngineDebug::queryAvailableEngines(QObject *parent)
{
Q_D(QmlEngineDebug);
@@ -332,6 +441,56 @@ QmlDebugObjectQuery *QmlEngineDebug::queryObjectRecursive(const QmlDebugObjectRe
return query;
}
+QmlDebugWatch::QmlDebugWatch(QObject *parent)
+: QObject(parent), m_state(Waiting), m_queryId(-1), m_objectDebugId(-1)
+{
+}
+
+int QmlDebugWatch::queryId() const
+{
+ return m_queryId;
+}
+
+int QmlDebugWatch::objectDebugId() const
+{
+ return m_objectDebugId;
+}
+
+QmlDebugWatch::State QmlDebugWatch::state() const
+{
+ return m_state;
+}
+
+void QmlDebugWatch::setState(State s)
+{
+ if (m_state == s)
+ return;
+ m_state = s;
+ emit stateChanged(m_state);
+}
+
+QmlDebugPropertyWatch::QmlDebugPropertyWatch(QObject *parent)
+ : QmlDebugWatch(parent)
+{
+}
+
+QString QmlDebugPropertyWatch::name() const
+{
+ return m_name;
+}
+
+
+QmlDebugObjectExpressionWatch::QmlDebugObjectExpressionWatch(QObject *parent)
+ : QmlDebugWatch(parent)
+{
+}
+
+QString QmlDebugObjectExpressionWatch::expression() const
+{
+ return m_expr;
+}
+
+
QmlDebugQuery::QmlDebugQuery(QObject *parent)
: QObject(parent), m_state(Waiting)
{
@@ -436,18 +595,19 @@ QString QmlDebugEngineReference::name() const
}
QmlDebugObjectReference::QmlDebugObjectReference()
-: m_debugId(-1)
+: m_debugId(-1), m_contextDebugId(-1)
{
}
QmlDebugObjectReference::QmlDebugObjectReference(int debugId)
-: m_debugId(debugId)
+: m_debugId(debugId), m_contextDebugId(-1)
{
}
QmlDebugObjectReference::QmlDebugObjectReference(const QmlDebugObjectReference &o)
-: m_debugId(o.m_debugId), m_class(o.m_class), m_name(o.m_name),
- m_source(o.m_source), m_properties(o.m_properties), m_children(o.m_children)
+: m_debugId(o.m_debugId), m_class(o.m_class), 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)
{
}
@@ -455,8 +615,8 @@ QmlDebugObjectReference &
QmlDebugObjectReference::operator=(const QmlDebugObjectReference &o)
{
m_debugId = o.m_debugId; m_class = o.m_class; m_name = o.m_name;
- m_source = o.m_source; m_properties = o.m_properties;
- m_children = o.m_children;
+ m_source = o.m_source; m_contextDebugId = o.m_contextDebugId;
+ m_properties = o.m_properties; m_children = o.m_children;
return *this;
}
@@ -480,6 +640,11 @@ QmlDebugFileReference QmlDebugObjectReference::source() const
return m_source;
}
+int QmlDebugObjectReference::contextDebugId() const
+{
+ return m_contextDebugId;
+}
+
QList<QmlDebugPropertyReference> QmlDebugObjectReference::properties() const
{
return m_properties;
@@ -574,20 +739,26 @@ void QmlDebugFileReference::setColumnNumber(int c)
}
QmlDebugPropertyReference::QmlDebugPropertyReference()
+: m_objectDebugId(-1)
{
}
QmlDebugPropertyReference::QmlDebugPropertyReference(const QmlDebugPropertyReference &o)
-: m_name(o.m_name), m_value(o.m_value), m_binding(o.m_binding)
+: m_objectDebugId(o.m_objectDebugId), m_name(o.m_name), m_value(o.m_value), m_binding(o.m_binding)
{
}
QmlDebugPropertyReference &QmlDebugPropertyReference::operator=(const QmlDebugPropertyReference &o)
{
- m_name = o.m_name; m_value = o.m_value; m_binding = o.m_binding;
+ m_objectDebugId = o.m_objectDebugId; m_name = o.m_name; m_value = o.m_value; m_binding = o.m_binding;
return *this;
}
+int QmlDebugPropertyReference::objectDebugId() const
+{
+ return m_objectDebugId;
+}
+
QString QmlDebugPropertyReference::name() const
{
return m_name;
diff --git a/src/declarative/debugger/qmldebug.h b/src/declarative/debugger/qmldebug.h
index 11e6b3e..be28a7e 100644
--- a/src/declarative/debugger/qmldebug.h
+++ b/src/declarative/debugger/qmldebug.h
@@ -7,6 +7,8 @@
class QmlDebugConnection;
class QmlDebugWatch;
+class QmlDebugPropertyWatch;
+class QmlDebugObjectExpressionWatch;
class QmlDebugEnginesQuery;
class QmlDebugRootContextQuery;
class QmlDebugObjectQuery;
@@ -22,17 +24,19 @@ Q_OBJECT
public:
QmlEngineDebug(QmlDebugConnection *, QObject * = 0);
- QmlDebugWatch *addWatch(const QmlDebugPropertyReference &,
+ QmlDebugPropertyWatch *addWatch(const QmlDebugPropertyReference &,
QObject *parent = 0);
QmlDebugWatch *addWatch(const QmlDebugContextReference &, const QString &,
QObject *parent = 0);
- QmlDebugWatch *addWatch(const QmlDebugObjectReference &, const QString &,
+ QmlDebugObjectExpressionWatch *addWatch(const QmlDebugObjectReference &, const QString &,
QObject *parent = 0);
QmlDebugWatch *addWatch(const QmlDebugObjectReference &,
QObject *parent = 0);
QmlDebugWatch *addWatch(const QmlDebugFileReference &,
QObject *parent = 0);
+ void removeWatch(QmlDebugWatch *watch);
+
QmlDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0);
QmlDebugRootContextQuery *queryRootContexts(const QmlDebugEngineReference &,
QObject *parent = 0);
@@ -51,14 +55,57 @@ Q_OBJECT
public:
enum State { Waiting, Active, Inactive, Dead };
+ QmlDebugWatch(QObject *);
+
+ int queryId() const;
+ int objectDebugId() const;
State state() const;
signals:
void stateChanged(State);
- void objectChanged(int, const QmlDebugObjectReference &);
- void valueChanged(int, const QVariant &);
+ //void objectChanged(int, const QmlDebugObjectReference &);
+ //void valueChanged(int, const QVariant &);
+
+ // Server sends value as string if it is a user-type variant
+ void valueChanged(const QByteArray &name, const QVariant &value);
+
+private:
+ friend class QmlEngineDebug;
+ friend class QmlEngineDebugPrivate;
+ void setState(State);
+ State m_state;
+ int m_queryId;
+ int m_objectDebugId;
+};
+
+class Q_DECLARATIVE_EXPORT QmlDebugPropertyWatch : public QmlDebugWatch
+{
+ Q_OBJECT
+public:
+ QmlDebugPropertyWatch(QObject *parent);
+
+ QString name() const;
+
+private:
+ friend class QmlEngineDebug;
+ QString m_name;
};
+class Q_DECLARATIVE_EXPORT QmlDebugObjectExpressionWatch : public QmlDebugWatch
+{
+ Q_OBJECT
+public:
+ QmlDebugObjectExpressionWatch(QObject *parent);
+
+ QString expression() const;
+
+private:
+ friend class QmlEngineDebug;
+ QString m_expr;
+ int m_debugId;
+};
+
+
class Q_DECLARATIVE_EXPORT QmlDebugQuery : public QObject
{
Q_OBJECT
@@ -134,6 +181,7 @@ public:
QString name() const;
QmlDebugFileReference source() const;
+ int contextDebugId() const;
QList<QmlDebugPropertyReference> properties() const;
QList<QmlDebugObjectReference> children() const;
@@ -144,6 +192,7 @@ private:
QString m_class;
QString m_name;
QmlDebugFileReference m_source;
+ int m_contextDebugId;
QList<QmlDebugPropertyReference> m_properties;
QList<QmlDebugObjectReference> m_children;
};
@@ -176,12 +225,14 @@ public:
QmlDebugPropertyReference(const QmlDebugPropertyReference &);
QmlDebugPropertyReference &operator=(const QmlDebugPropertyReference &);
+ int objectDebugId() const;
QString name() const;
QVariant value() const;
QString binding() const;
private:
friend class QmlEngineDebugPrivate;
+ int m_objectDebugId;
QString m_name;
QVariant m_value;
QString m_binding;
diff --git a/src/declarative/debugger/qmldebugservice.h b/src/declarative/debugger/qmldebugservice.h
index c3c3b01..5d20ba0 100644
--- a/src/declarative/debugger/qmldebugservice.h
+++ b/src/declarative/debugger/qmldebugservice.h
@@ -49,7 +49,7 @@ QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
class QmlDebugServicePrivate;
-class QmlDebugService : public QObject
+class Q_DECLARATIVE_EXPORT QmlDebugService : public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(QmlDebugService)