aboutsummaryrefslogtreecommitdiffstats
path: root/src/declarative/debugger
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@nokia.com>2011-09-12 08:12:58 +0200
committerGunnar Sletta <gunnar.sletta@nokia.com>2011-09-12 08:12:58 +0200
commitd77218522eb480c8d528de18049cd7b604cdeb2a (patch)
treea6433a8e9205a95006eae10b53285a0e3487423d /src/declarative/debugger
parent589c8445e2623ef8e0b8294d7c558a2948b2a5e3 (diff)
parentd5686fa2ac2248d5a31237573fa08697f18f035f (diff)
Merge branch 'master' into refactor
Conflicts: examples/declarative/cppextensions/qwidgets/qwidgets.pro examples/declarative/minehunt/main.cpp examples/declarative/minehunt/minehunt.pro src/declarative/items/context2d/qsgcontext2d.cpp src/declarative/items/qsgflickable.cpp src/declarative/items/qsgtextedit.cpp src/declarative/items/qsgtextinput.cpp src/declarative/particles/qsgangleddirection.cpp src/declarative/particles/qsgcumulativedirection.cpp src/declarative/particles/qsgcumulativedirection_p.h src/declarative/particles/qsgfollowemitter.cpp src/declarative/particles/qsgmodelparticle.cpp src/declarative/particles/qsgparticlesystem.cpp src/qtquick1/util/qdeclarativeview.h tests/auto/declarative/examples/examples.pro tests/auto/declarative/qsgfocusscope/tst_qsgfocusscope.cpp Change-Id: Ib4be2a5e742dee1a399d73da97161736f77448e5
Diffstat (limited to 'src/declarative/debugger')
-rw-r--r--src/declarative/debugger/debugger.pri11
-rw-r--r--src/declarative/debugger/qdeclarativedebug.h67
-rw-r--r--src/declarative/debugger/qdeclarativedebugclient.cpp118
-rw-r--r--src/declarative/debugger/qdeclarativedebugclient_p.h33
-rw-r--r--src/declarative/debugger/qdeclarativedebuggerstatus_p.h11
-rw-r--r--src/declarative/debugger/qdeclarativedebughelper_p.h11
-rw-r--r--src/declarative/debugger/qdeclarativedebugserver.cpp10
-rw-r--r--src/declarative/debugger/qdeclarativedebugserver_p.h11
-rw-r--r--src/declarative/debugger/qdeclarativedebugserverconnection_p.h11
-rw-r--r--src/declarative/debugger/qdeclarativedebugservice.cpp42
-rw-r--r--src/declarative/debugger/qdeclarativedebugservice_p.h11
-rw-r--r--src/declarative/debugger/qdeclarativedebugservice_p_p.h11
-rw-r--r--src/declarative/debugger/qdeclarativedebugtrace.cpp16
-rw-r--r--src/declarative/debugger/qdeclarativedebugtrace_p.h11
-rw-r--r--src/declarative/debugger/qdeclarativeenginedebug.cpp (renamed from src/declarative/debugger/qdeclarativedebug.cpp)116
-rw-r--r--src/declarative/debugger/qdeclarativeenginedebug_p.h (renamed from src/declarative/debugger/qdeclarativedebug_p.h)59
-rw-r--r--src/declarative/debugger/qdeclarativeenginedebugservice.cpp747
-rw-r--r--src/declarative/debugger/qdeclarativeenginedebugservice_p.h134
-rw-r--r--src/declarative/debugger/qdeclarativeinspectorinterface_p.h17
-rw-r--r--src/declarative/debugger/qdeclarativeinspectorservice_p.h17
-rw-r--r--src/declarative/debugger/qpacketprotocol.cpp56
-rw-r--r--src/declarative/debugger/qpacketprotocol_p.h25
-rw-r--r--src/declarative/debugger/qv8debugservice.cpp7
23 files changed, 1378 insertions, 174 deletions
diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri
index e7462d4e78..a257da216f 100644
--- a/src/declarative/debugger/debugger.pri
+++ b/src/declarative/debugger/debugger.pri
@@ -5,12 +5,13 @@ SOURCES += \
$$PWD/qpacketprotocol.cpp \
$$PWD/qdeclarativedebugservice.cpp \
$$PWD/qdeclarativedebugclient.cpp \
- $$PWD/qdeclarativedebug.cpp \
+ $$PWD/qdeclarativeenginedebug.cpp \
$$PWD/qdeclarativedebugtrace.cpp \
$$PWD/qdeclarativedebughelper.cpp \
$$PWD/qdeclarativedebugserver.cpp \
$$PWD/qdeclarativeinspectorservice.cpp \
- $$PWD/qv8debugservice.cpp
+ $$PWD/qv8debugservice.cpp \
+ $$PWD/qdeclarativeenginedebugservice.cpp
HEADERS += \
$$PWD/qdeclarativedebuggerstatus_p.h \
@@ -18,11 +19,13 @@ HEADERS += \
$$PWD/qdeclarativedebugservice_p.h \
$$PWD/qdeclarativedebugservice_p_p.h \
$$PWD/qdeclarativedebugclient_p.h \
- $$PWD/qdeclarativedebug_p.h \
+ $$PWD/qdeclarativeenginedebug_p.h \
$$PWD/qdeclarativedebugtrace_p.h \
$$PWD/qdeclarativedebughelper_p.h \
$$PWD/qdeclarativedebugserver_p.h \
$$PWD/qdeclarativedebugserverconnection_p.h \
$$PWD/qdeclarativeinspectorservice_p.h \
$$PWD/qdeclarativeinspectorinterface_p.h \
- $$PWD/qv8debugservice_p.h
+ $$PWD/qv8debugservice_p.h \
+ $$PWD/qdeclarativeenginedebugservice_p.h \
+ $$PWD/qdeclarativedebug.h
diff --git a/src/declarative/debugger/qdeclarativedebug.h b/src/declarative/debugger/qdeclarativedebug.h
new file mode 100644
index 0000000000..b7930b21f0
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativedebug.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEDEBUG_H
+#define QDECLARATIVEDEBUG_H
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+struct Q_DECLARATIVE_EXPORT QDeclarativeDebuggingEnabler
+{
+ QDeclarativeDebuggingEnabler();
+};
+
+// Execute code in constructor before first QDeclarativeEngine is instantiated
+#if defined(QT_DECLARATIVE_DEBUG)
+static QDeclarativeDebuggingEnabler qmlEnableDebuggingHelper;
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEDEBUG_H
diff --git a/src/declarative/debugger/qdeclarativedebugclient.cpp b/src/declarative/debugger/qdeclarativedebugclient.cpp
index d3617b19b5..606ad2deae 100644
--- a/src/declarative/debugger/qdeclarativedebugclient.cpp
+++ b/src/declarative/debugger/qdeclarativedebugclient.cpp
@@ -45,6 +45,7 @@
#include <QtCore/qdebug.h>
#include <QtCore/qstringlist.h>
+#include <QtNetwork/qnetworkproxy.h>
#include <private/qobject_p.h>
@@ -71,20 +72,23 @@ public:
QDeclarativeDebugConnectionPrivate(QDeclarativeDebugConnection *c);
QDeclarativeDebugConnection *q;
QPacketProtocol *protocol;
+ QIODevice *device;
bool gotHello;
QStringList serverPlugins;
QHash<QString, QDeclarativeDebugClient *> plugins;
void advertisePlugins();
+ void connectDeviceSignals();
public Q_SLOTS:
void connected();
void readyRead();
+ void deviceAboutToClose();
};
QDeclarativeDebugConnectionPrivate::QDeclarativeDebugConnectionPrivate(QDeclarativeDebugConnection *c)
-: QObject(c), q(c), protocol(0), gotHello(false)
+ : QObject(c), q(c), protocol(0), device(0), gotHello(false)
{
protocol = new QPacketProtocol(q, this);
QObject::connect(c, SIGNAL(connected()), this, SLOT(connected()));
@@ -137,7 +141,6 @@ void QDeclarativeDebugConnectionPrivate::readyRead()
QObject::disconnect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead()));
return;
}
-
gotHello = true;
QHash<QString, QDeclarativeDebugClient *>::Iterator iter = plugins.begin();
@@ -183,7 +186,7 @@ void QDeclarativeDebugConnectionPrivate::readyRead()
pack >> message;
QHash<QString, QDeclarativeDebugClient *>::Iterator iter =
- plugins.find(name);
+ plugins.find(name);
if (iter == plugins.end()) {
qWarning() << "QDeclarativeDebugConnection: Message received for missing plugin" << name;
} else {
@@ -193,8 +196,15 @@ void QDeclarativeDebugConnectionPrivate::readyRead()
}
}
+void QDeclarativeDebugConnectionPrivate::deviceAboutToClose()
+{
+ // This is nasty syntax but we want to emit our own aboutToClose signal (by calling QIODevice::close())
+ // without calling the underlying device close fn as that would cause an infinite loop
+ q->QIODevice::close();
+}
+
QDeclarativeDebugConnection::QDeclarativeDebugConnection(QObject *parent)
-: QTcpSocket(parent), d(new QDeclarativeDebugConnectionPrivate(this))
+ : QIODevice(parent), d(new QDeclarativeDebugConnectionPrivate(this))
{
}
@@ -202,24 +212,107 @@ QDeclarativeDebugConnection::~QDeclarativeDebugConnection()
{
QHash<QString, QDeclarativeDebugClient*>::iterator iter = d->plugins.begin();
for (; iter != d->plugins.end(); ++iter) {
- iter.value()->d_func()->connection = 0;
- iter.value()->statusChanged(QDeclarativeDebugClient::NotConnected);
+ iter.value()->d_func()->connection = 0;
+ iter.value()->statusChanged(QDeclarativeDebugClient::NotConnected);
}
}
bool QDeclarativeDebugConnection::isConnected() const
{
- return state() == ConnectedState;
+ return state() == QAbstractSocket::ConnectedState;
+}
+
+qint64 QDeclarativeDebugConnection::readData(char *data, qint64 maxSize)
+{
+ return d->device->read(data, maxSize);
+}
+
+qint64 QDeclarativeDebugConnection::writeData(const char *data, qint64 maxSize)
+{
+ return d->device->write(data, maxSize);
+}
+
+qint64 QDeclarativeDebugConnection::bytesAvailable() const
+{
+ return d->device->bytesAvailable();
+}
+
+bool QDeclarativeDebugConnection::isSequential() const
+{
+ return true;
}
+void QDeclarativeDebugConnection::close()
+{
+ if (isOpen()) {
+ QIODevice::close();
+ d->device->close();
+ emit stateChanged(QAbstractSocket::UnconnectedState);
+
+ QHash<QString, QDeclarativeDebugClient*>::iterator iter = d->plugins.begin();
+ for (; iter != d->plugins.end(); ++iter) {
+ iter.value()->statusChanged(QDeclarativeDebugClient::NotConnected);
+ }
+ }
+}
+
+bool QDeclarativeDebugConnection::waitForConnected(int msecs)
+{
+ QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device);
+ if (socket)
+ return socket->waitForConnected(msecs);
+ return false;
+}
+
+QAbstractSocket::SocketState QDeclarativeDebugConnection::state() const
+{
+ QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device);
+ if (socket)
+ return socket->state();
+
+ return QAbstractSocket::UnconnectedState;
+}
+
+void QDeclarativeDebugConnection::flush()
+{
+ QAbstractSocket *socket = qobject_cast<QAbstractSocket*>(d->device);
+ if (socket) {
+ socket->flush();
+ return;
+ }
+}
+
+void QDeclarativeDebugConnection::connectToHost(const QString &hostName, quint16 port)
+{
+ QTcpSocket *socket = new QTcpSocket(d);
+ socket->setProxy(QNetworkProxy::NoProxy);
+ d->device = socket;
+ d->connectDeviceSignals();
+ d->gotHello = false;
+ connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SIGNAL(stateChanged(QAbstractSocket::SocketState)));
+ connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(error(QAbstractSocket::SocketError)));
+ connect(socket, SIGNAL(connected()), this, SIGNAL(connected()));
+ socket->connectToHost(hostName, port);
+ QIODevice::open(ReadWrite | Unbuffered);
+}
+
+void QDeclarativeDebugConnectionPrivate::connectDeviceSignals()
+{
+ connect(device, SIGNAL(bytesWritten(qint64)), q, SIGNAL(bytesWritten(qint64)));
+ connect(device, SIGNAL(readyRead()), q, SIGNAL(readyRead()));
+ connect(device, SIGNAL(aboutToClose()), this, SLOT(deviceAboutToClose()));
+}
+
+//
+
QDeclarativeDebugClientPrivate::QDeclarativeDebugClientPrivate()
-: connection(0)
+ : connection(0)
{
}
QDeclarativeDebugClient::QDeclarativeDebugClient(const QString &name,
- QDeclarativeDebugConnection *parent)
-: QObject(*(new QDeclarativeDebugClientPrivate), parent)
+ QDeclarativeDebugConnection *parent)
+ : QObject(*(new QDeclarativeDebugClientPrivate), parent)
{
Q_D(QDeclarativeDebugClient);
d->name = name;
@@ -239,7 +332,7 @@ QDeclarativeDebugClient::QDeclarativeDebugClient(const QString &name,
QDeclarativeDebugClient::~QDeclarativeDebugClient()
{
- Q_D(const QDeclarativeDebugClient);
+ Q_D(QDeclarativeDebugClient);
if (d->connection && d->connection->d) {
d->connection->d->plugins.remove(d->name);
d->connection->d->advertisePlugins();
@@ -269,14 +362,13 @@ QDeclarativeDebugClient::Status QDeclarativeDebugClient::status() const
void QDeclarativeDebugClient::sendMessage(const QByteArray &message)
{
Q_D(QDeclarativeDebugClient);
-
if (status() != Enabled)
return;
QPacket pack;
pack << d->name << message;
d->connection->d->protocol->send(pack);
- d->connection->d->q->flush();
+ d->connection->flush();
}
void QDeclarativeDebugClient::statusChanged(Status)
diff --git a/src/declarative/debugger/qdeclarativedebugclient_p.h b/src/declarative/debugger/qdeclarativedebugclient_p.h
index a2648d61c2..5b219358ff 100644
--- a/src/declarative/debugger/qdeclarativedebugclient_p.h
+++ b/src/declarative/debugger/qdeclarativedebugclient_p.h
@@ -42,6 +42,17 @@
#ifndef QDECLARATIVEDEBUGCLIENT_H
#define QDECLARATIVEDEBUGCLIENT_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtNetwork/qtcpsocket.h>
#include <private/qdeclarativeglobal_p.h>
@@ -53,7 +64,7 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Declarative)
class QDeclarativeDebugConnectionPrivate;
-class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugConnection : public QTcpSocket
+class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugConnection : public QIODevice
{
Q_OBJECT
Q_DISABLE_COPY(QDeclarativeDebugConnection)
@@ -61,7 +72,25 @@ public:
QDeclarativeDebugConnection(QObject * = 0);
~QDeclarativeDebugConnection();
+ void connectToHost(const QString &hostName, quint16 port);
+
+ qint64 bytesAvailable() const;
bool isConnected() const;
+ QAbstractSocket::SocketState state() const;
+ void flush();
+ bool isSequential() const;
+ void close();
+ bool waitForConnected(int msecs = 30000);
+
+signals:
+ void connected();
+ void stateChanged(QAbstractSocket::SocketState socketState);
+ void error(QAbstractSocket::SocketError socketError);
+
+protected:
+ qint64 readData(char *data, qint64 maxSize);
+ qint64 writeData(const char *data, qint64 maxSize);
+
private:
QDeclarativeDebugConnectionPrivate *d;
friend class QDeclarativeDebugClient;
@@ -85,7 +114,7 @@ public:
Status status() const;
- void sendMessage(const QByteArray &);
+ virtual void sendMessage(const QByteArray &);
protected:
virtual void statusChanged(Status);
diff --git a/src/declarative/debugger/qdeclarativedebuggerstatus_p.h b/src/declarative/debugger/qdeclarativedebuggerstatus_p.h
index 7904a06af6..385301e62d 100644
--- a/src/declarative/debugger/qdeclarativedebuggerstatus_p.h
+++ b/src/declarative/debugger/qdeclarativedebuggerstatus_p.h
@@ -42,6 +42,17 @@
#ifndef QDECLARATIVEDEBUGGERSTATUS_P_H
#define QDECLARATIVEDEBUGGERSTATUS_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtCore/qobject.h>
#include <private/qdeclarativeglobal_p.h>
diff --git a/src/declarative/debugger/qdeclarativedebughelper_p.h b/src/declarative/debugger/qdeclarativedebughelper_p.h
index d9ed5796ee..b92f3ba975 100644
--- a/src/declarative/debugger/qdeclarativedebughelper_p.h
+++ b/src/declarative/debugger/qdeclarativedebughelper_p.h
@@ -46,6 +46,17 @@
#include <private/qdeclarativeglobal_p.h>
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativedebugserver.cpp b/src/declarative/debugger/qdeclarativedebugserver.cpp
index 6e2db4f605..8bda0062f9 100644
--- a/src/declarative/debugger/qdeclarativedebugserver.cpp
+++ b/src/declarative/debugger/qdeclarativedebugserver.cpp
@@ -120,7 +120,7 @@ void QDeclarativeDebugServerPrivate::advertisePlugins()
}
QDeclarativeDebugServerConnection *QDeclarativeDebugServerPrivate::loadConnectionPlugin(
- const QString &pluginName)
+ const QString &pluginName)
{
QStringList pluginCandidates;
const QStringList paths = QCoreApplication::libraryPaths();
@@ -178,9 +178,9 @@ QDeclarativeDebugServer *QDeclarativeDebugServer::instance()
if (!appD->qmljsDebugArgumentsString().isEmpty()) {
if (!QDeclarativeEnginePrivate::qml_debugging_enabled) {
const QString message =
- QString::fromAscii("QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
- "Debugging has not been enabled.").arg(
- appD->qmljsDebugArgumentsString());
+ QString::fromAscii("QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". "
+ "Debugging has not been enabled.").arg(
+ appD->qmljsDebugArgumentsString());
qWarning("%s", qPrintable(message));
return 0;
}
@@ -231,7 +231,7 @@ QDeclarativeDebugServer *QDeclarativeDebugServer::instance()
}
QDeclarativeDebugServer::QDeclarativeDebugServer()
-: QObject(*(new QDeclarativeDebugServerPrivate))
+ : QObject(*(new QDeclarativeDebugServerPrivate))
{
}
diff --git a/src/declarative/debugger/qdeclarativedebugserver_p.h b/src/declarative/debugger/qdeclarativedebugserver_p.h
index 53c1077c7b..d80633cd7d 100644
--- a/src/declarative/debugger/qdeclarativedebugserver_p.h
+++ b/src/declarative/debugger/qdeclarativedebugserver_p.h
@@ -45,6 +45,17 @@
#include <private/qdeclarativeglobal_p.h>
#include <private/qdeclarativedebugserverconnection_p.h>
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h b/src/declarative/debugger/qdeclarativedebugserverconnection_p.h
index d7f0de62fa..832224ea33 100644
--- a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h
+++ b/src/declarative/debugger/qdeclarativedebugserverconnection_p.h
@@ -44,6 +44,17 @@
#include <QtDeclarative/private/qdeclarativeglobal_p.h>
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativedebugservice.cpp b/src/declarative/debugger/qdeclarativedebugservice.cpp
index 7274211bf2..ecd9e0fb85 100644
--- a/src/declarative/debugger/qdeclarativedebugservice.cpp
+++ b/src/declarative/debugger/qdeclarativedebugservice.cpp
@@ -49,12 +49,12 @@
QT_BEGIN_NAMESPACE
QDeclarativeDebugServicePrivate::QDeclarativeDebugServicePrivate()
-: server(0)
+ : server(0)
{
}
QDeclarativeDebugService::QDeclarativeDebugService(const QString &name, QObject *parent)
-: QObject(*(new QDeclarativeDebugServicePrivate), parent)
+ : QObject(*(new QDeclarativeDebugServicePrivate), parent)
{
Q_D(QDeclarativeDebugService);
d->name = name;
@@ -114,21 +114,21 @@ QDeclarativeDebugService::Status QDeclarativeDebugService::status() const
namespace {
- struct ObjectReference
- {
- QPointer<QObject> object;
- int id;
- };
+struct ObjectReference
+{
+ QPointer<QObject> object;
+ int id;
+};
- struct ObjectReferenceHash
- {
- ObjectReferenceHash() : nextId(0) {}
+struct ObjectReferenceHash
+{
+ ObjectReferenceHash() : nextId(0) {}
- QHash<QObject *, ObjectReference> objects;
- QHash<int, QObject *> ids;
+ QHash<QObject *, ObjectReference> objects;
+ QHash<int, QObject *> ids;
- int nextId;
- };
+ int nextId;
+};
}
Q_GLOBAL_STATIC(ObjectReferenceHash, objectReferenceHash);
@@ -144,8 +144,8 @@ int QDeclarativeDebugService::idForObject(QObject *object)
return -1;
ObjectReferenceHash *hash = objectReferenceHash();
- QHash<QObject *, ObjectReference>::Iterator iter =
- hash->objects.find(object);
+ QHash<QObject *, ObjectReference>::Iterator iter =
+ hash->objects.find(object);
if (iter == hash->objects.end()) {
int id = hash->nextId++;
@@ -162,7 +162,7 @@ int QDeclarativeDebugService::idForObject(QObject *object)
hash->ids.insert(id, object);
iter->object = object;
iter->id = id;
- }
+ }
return iter->id;
}
@@ -180,8 +180,8 @@ QObject *QDeclarativeDebugService::objectForId(int id)
return 0;
- QHash<QObject *, ObjectReference>::Iterator objIter =
- hash->objects.find(*iter);
+ QHash<QObject *, ObjectReference>::Iterator objIter =
+ hash->objects.find(*iter);
Q_ASSERT(objIter != hash->objects.end());
if (objIter->object == 0) {
@@ -213,8 +213,8 @@ QString QDeclarativeDebugService::objectToString(QObject *obj)
if(objectName.isEmpty())
objectName = QLatin1String("<unnamed>");
- QString rv = QString::fromUtf8(obj->metaObject()->className()) +
- QLatin1String(": ") + objectName;
+ QString rv = QString::fromUtf8(obj->metaObject()->className()) +
+ QLatin1String(": ") + objectName;
return rv;
}
diff --git a/src/declarative/debugger/qdeclarativedebugservice_p.h b/src/declarative/debugger/qdeclarativedebugservice_p.h
index 84e63c0ddc..05580ee5c2 100644
--- a/src/declarative/debugger/qdeclarativedebugservice_p.h
+++ b/src/declarative/debugger/qdeclarativedebugservice_p.h
@@ -46,6 +46,17 @@
#include <private/qdeclarativeglobal_p.h>
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativedebugservice_p_p.h b/src/declarative/debugger/qdeclarativedebugservice_p_p.h
index 78076892cb..12233ed739 100644
--- a/src/declarative/debugger/qdeclarativedebugservice_p_p.h
+++ b/src/declarative/debugger/qdeclarativedebugservice_p_p.h
@@ -42,6 +42,17 @@
#ifndef QDECLARATIVEDEBUGSERVICE_P_H
#define QDECLARATIVEDEBUGSERVICE_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtCore/qglobal.h>
#include <private/qobject_p.h>
diff --git a/src/declarative/debugger/qdeclarativedebugtrace.cpp b/src/declarative/debugger/qdeclarativedebugtrace.cpp
index 0a46d68aa7..befc3ea374 100644
--- a/src/declarative/debugger/qdeclarativedebugtrace.cpp
+++ b/src/declarative/debugger/qdeclarativedebugtrace.cpp
@@ -45,6 +45,8 @@
#include <QtCore/qurl.h>
#include <QtCore/qtimer.h>
+QT_BEGIN_NAMESPACE
+
Q_GLOBAL_STATIC(QDeclarativeDebugTrace, traceInstance);
// convert to a QByteArray that can be sent to the debug client
@@ -64,8 +66,8 @@ QByteArray QDeclarativeDebugData::toByteArray() const
}
QDeclarativeDebugTrace::QDeclarativeDebugTrace()
-: QDeclarativeDebugService(QLatin1String("CanvasFrameRate")),
- m_enabled(false), m_deferredSend(true), m_messageReceived(false)
+ : QDeclarativeDebugService(QLatin1String("CanvasFrameRate")),
+ m_enabled(false), m_deferredSend(true), m_messageReceived(false)
{
m_timer.start();
if (status() == Enabled) {
@@ -77,19 +79,19 @@ QDeclarativeDebugTrace::QDeclarativeDebugTrace()
void QDeclarativeDebugTrace::addEvent(EventType t)
{
- if (QDeclarativeDebugService::isDebuggingEnabled())
+ if (QDeclarativeDebugService::isDebuggingEnabled())
traceInstance()->addEventImpl(t);
}
void QDeclarativeDebugTrace::startRange(RangeType t)
{
- if (QDeclarativeDebugService::isDebuggingEnabled())
+ if (QDeclarativeDebugService::isDebuggingEnabled())
traceInstance()->startRangeImpl(t);
}
void QDeclarativeDebugTrace::rangeData(RangeType t, const QString &data)
{
- if (QDeclarativeDebugService::isDebuggingEnabled())
+ if (QDeclarativeDebugService::isDebuggingEnabled())
traceInstance()->rangeDataImpl(t, data);
}
@@ -113,7 +115,7 @@ void QDeclarativeDebugTrace::rangeLocation(RangeType t, const QUrl &fileName, in
void QDeclarativeDebugTrace::endRange(RangeType t)
{
- if (QDeclarativeDebugService::isDebuggingEnabled())
+ if (QDeclarativeDebugService::isDebuggingEnabled())
traceInstance()->endRangeImpl(t);
}
@@ -223,3 +225,5 @@ void QDeclarativeDebugTrace::messageReceived(const QByteArray &message)
if (!m_enabled)
sendMessages();
}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativedebugtrace_p.h b/src/declarative/debugger/qdeclarativedebugtrace_p.h
index f2710cde93..fb2ef53a4a 100644
--- a/src/declarative/debugger/qdeclarativedebugtrace_p.h
+++ b/src/declarative/debugger/qdeclarativedebugtrace_p.h
@@ -42,6 +42,17 @@
#ifndef QDECLARATIVEDEBUGTRACE_P_H
#define QDECLARATIVEDEBUGTRACE_P_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <private/qdeclarativedebugservice_p.h>
#include <QtCore/qelapsedtimer.h>
diff --git a/src/declarative/debugger/qdeclarativedebug.cpp b/src/declarative/debugger/qdeclarativeenginedebug.cpp
index 620ee1d66a..237e2d6376 100644
--- a/src/declarative/debugger/qdeclarativedebug.cpp
+++ b/src/declarative/debugger/qdeclarativeenginedebug.cpp
@@ -39,11 +39,11 @@
**
****************************************************************************/
-#include "private/qdeclarativedebug_p.h"
+#include "private/qdeclarativeenginedebug_p.h"
#include "private/qdeclarativedebugclient_p.h"
-#include <qdeclarativeenginedebug_p.h>
+#include <qdeclarativeenginedebugservice_p.h>
#include <private/qobject_p.h>
@@ -95,8 +95,8 @@ public:
};
QDeclarativeEngineDebugClient::QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client,
- QDeclarativeEngineDebugPrivate *p)
-: QDeclarativeDebugClient(QLatin1String("QDeclarativeEngine"), client), priv(p)
+ QDeclarativeEngineDebugPrivate *p)
+ : QDeclarativeDebugClient(QLatin1String("QDeclarativeEngine"), client), priv(p)
{
}
@@ -113,7 +113,7 @@ void QDeclarativeEngineDebugClient::messageReceived(const QByteArray &data)
}
QDeclarativeEngineDebugPrivate::QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *c)
-: client(new QDeclarativeEngineDebugClient(c, this)), nextId(0)
+ : client(new QDeclarativeEngineDebugClient(c, this)), nextId(0)
{
}
@@ -172,7 +172,7 @@ void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclara
}
void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c,
- QDeclarativeDebugRootContextQuery *q)
+ QDeclarativeDebugRootContextQuery *q)
{
if (c && q) {
QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c);
@@ -205,9 +205,9 @@ void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclara
}
void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugObjectReference &o,
- bool simple)
+ bool simple)
{
- QDeclarativeEngineDebugServer::QDeclarativeObjectData data;
+ QDeclarativeEngineDebugService::QDeclarativeObjectData data;
ds >> data;
o.m_debugId = data.objectId;
o.m_class = data.objectType;
@@ -234,7 +234,7 @@ void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugOb
ds >> propCount;
for (int ii = 0; ii < propCount; ++ii) {
- QDeclarativeEngineDebugServer::QDeclarativeObjectProperty data;
+ QDeclarativeEngineDebugService::QDeclarativeObjectProperty data;
ds >> data;
QDeclarativeDebugPropertyReference prop;
prop.m_objectDebugId = o.m_debugId;
@@ -243,22 +243,22 @@ void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugOb
prop.m_hasNotifySignal = data.hasNotifySignal;
prop.m_valueTypeName = data.valueTypeName;
switch (data.type) {
- case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::Basic:
- case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::List:
- case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::SignalProperty:
- {
- prop.m_value = data.value;
- break;
- }
- case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::Object:
- {
- QDeclarativeDebugObjectReference obj;
- obj.m_debugId = prop.m_value.toInt();
- prop.m_value = QVariant::fromValue(obj);
- break;
- }
- case QDeclarativeEngineDebugServer::QDeclarativeObjectProperty::Unknown:
- break;
+ case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Basic:
+ case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::List:
+ case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::SignalProperty:
+ {
+ prop.m_value = data.value;
+ break;
+ }
+ case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Object:
+ {
+ QDeclarativeDebugObjectReference obj;
+ obj.m_debugId = prop.m_value.toInt();
+ prop.m_value = QVariant::fromValue(obj);
+ break;
+ }
+ case QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Unknown:
+ break;
}
o.m_properties << prop;
}
@@ -332,7 +332,7 @@ void QDeclarativeEngineDebugPrivate::message(const QByteArray &data)
return;
rootContextQuery.remove(queryId);
- if (!ds.atEnd())
+ if (!ds.atEnd())
decode(ds, query->m_context);
query->m_client = 0;
@@ -411,7 +411,11 @@ void QDeclarativeEngineDebugPrivate::message(const QByteArray &data)
}
QDeclarativeEngineDebug::QDeclarativeEngineDebug(QDeclarativeDebugConnection *client, QObject *parent)
-: QObject(*(new QDeclarativeEngineDebugPrivate(client)), parent)
+ : QObject(*(new QDeclarativeEngineDebugPrivate(client)), parent)
+{
+}
+
+QDeclarativeEngineDebug::~QDeclarativeEngineDebug()
{
}
@@ -580,7 +584,7 @@ QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObject(const QDeclar
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId()
+ ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId()
<< false << true;
d->client->sendMessage(message);
} else {
@@ -603,7 +607,7 @@ QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObjectRecursive(cons
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
- ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId()
+ ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId()
<< true << true;
d->client->sendMessage(message);
} else {
@@ -686,7 +690,7 @@ bool QDeclarativeEngineDebug::setMethodBody(int objectDebugId, const QString &me
}
QDeclarativeDebugWatch::QDeclarativeDebugWatch(QObject *parent)
-: QObject(parent), m_state(Waiting), m_queryId(-1), m_client(0), m_objectDebugId(-1)
+ : QObject(parent), m_state(Waiting), m_queryId(-1), m_client(0), m_objectDebugId(-1)
{
}
@@ -742,7 +746,7 @@ QString QDeclarativeDebugObjectExpressionWatch::expression() const
QDeclarativeDebugQuery::QDeclarativeDebugQuery(QObject *parent)
-: QObject(parent), m_state(Waiting)
+ : QObject(parent), m_state(Waiting)
{
}
@@ -765,13 +769,13 @@ void QDeclarativeDebugQuery::setState(State s)
}
QDeclarativeDebugEnginesQuery::QDeclarativeDebugEnginesQuery(QObject *parent)
-: QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1)
+ : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1)
{
}
QDeclarativeDebugEnginesQuery::~QDeclarativeDebugEnginesQuery()
{
- if (m_client && m_queryId != -1)
+ if (m_client && m_queryId != -1)
QDeclarativeEngineDebugPrivate::remove(m_client, this);
}
@@ -781,13 +785,13 @@ QList<QDeclarativeDebugEngineReference> QDeclarativeDebugEnginesQuery::engines()
}
QDeclarativeDebugRootContextQuery::QDeclarativeDebugRootContextQuery(QObject *parent)
-: QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1)
+ : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1)
{
}
QDeclarativeDebugRootContextQuery::~QDeclarativeDebugRootContextQuery()
{
- if (m_client && m_queryId != -1)
+ if (m_client && m_queryId != -1)
QDeclarativeEngineDebugPrivate::remove(m_client, this);
}
@@ -797,13 +801,13 @@ QDeclarativeDebugContextReference QDeclarativeDebugRootContextQuery::rootContext
}
QDeclarativeDebugObjectQuery::QDeclarativeDebugObjectQuery(QObject *parent)
-: QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1)
+ : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1)
{
}
QDeclarativeDebugObjectQuery::~QDeclarativeDebugObjectQuery()
{
- if (m_client && m_queryId != -1)
+ if (m_client && m_queryId != -1)
QDeclarativeEngineDebugPrivate::remove(m_client, this);
}
@@ -813,13 +817,13 @@ QDeclarativeDebugObjectReference QDeclarativeDebugObjectQuery::object() const
}
QDeclarativeDebugExpressionQuery::QDeclarativeDebugExpressionQuery(QObject *parent)
-: QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1)
+ : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1)
{
}
QDeclarativeDebugExpressionQuery::~QDeclarativeDebugExpressionQuery()
{
- if (m_client && m_queryId != -1)
+ if (m_client && m_queryId != -1)
QDeclarativeEngineDebugPrivate::remove(m_client, this);
}
@@ -834,17 +838,17 @@ QVariant QDeclarativeDebugExpressionQuery::result() const
}
QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference()
-: m_debugId(-1)
+ : m_debugId(-1)
{
}
QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(int debugId)
-: m_debugId(debugId)
+ : m_debugId(debugId)
{
}
QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &o)
-: m_debugId(o.m_debugId), m_name(o.m_name)
+ : m_debugId(o.m_debugId), m_name(o.m_name)
{
}
@@ -866,19 +870,19 @@ QString QDeclarativeDebugEngineReference::name() const
}
QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference()
-: m_debugId(-1), m_contextDebugId(-1)
+ : m_debugId(-1), m_contextDebugId(-1)
{
}
QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(int debugId)
-: m_debugId(debugId), m_contextDebugId(-1)
+ : m_debugId(debugId), m_contextDebugId(-1)
{
}
QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(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_properties(o.m_properties), m_children(o.m_children)
+ : 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_properties(o.m_properties), m_children(o.m_children)
{
}
@@ -932,18 +936,18 @@ QList<QDeclarativeDebugObjectReference> QDeclarativeDebugObjectReference::childr
}
QDeclarativeDebugContextReference::QDeclarativeDebugContextReference()
-: m_debugId(-1)
+ : m_debugId(-1)
{
}
QDeclarativeDebugContextReference::QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &o)
-: m_debugId(o.m_debugId), m_name(o.m_name), m_objects(o.m_objects), m_contexts(o.m_contexts)
+ : m_debugId(o.m_debugId), m_name(o.m_name), m_objects(o.m_objects), m_contexts(o.m_contexts)
{
}
QDeclarativeDebugContextReference &QDeclarativeDebugContextReference::operator=(const QDeclarativeDebugContextReference &o)
{
- m_debugId = o.m_debugId; m_name = o.m_name; m_objects = o.m_objects;
+ m_debugId = o.m_debugId; m_name = o.m_name; m_objects = o.m_objects;
m_contexts = o.m_contexts;
return *this;
}
@@ -969,12 +973,12 @@ QList<QDeclarativeDebugContextReference> QDeclarativeDebugContextReference::cont
}
QDeclarativeDebugFileReference::QDeclarativeDebugFileReference()
-: m_lineNumber(-1), m_columnNumber(-1)
+ : m_lineNumber(-1), m_columnNumber(-1)
{
}
QDeclarativeDebugFileReference::QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &o)
-: m_url(o.m_url), m_lineNumber(o.m_lineNumber), m_columnNumber(o.m_columnNumber)
+ : m_url(o.m_url), m_lineNumber(o.m_lineNumber), m_columnNumber(o.m_columnNumber)
{
}
@@ -1015,14 +1019,14 @@ void QDeclarativeDebugFileReference::setColumnNumber(int c)
}
QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference()
-: m_objectDebugId(-1), m_hasNotifySignal(false)
+ : m_objectDebugId(-1), m_hasNotifySignal(false)
{
}
QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &o)
-: m_objectDebugId(o.m_objectDebugId), m_name(o.m_name), m_value(o.m_value),
- m_valueTypeName(o.m_valueTypeName), m_binding(o.m_binding),
- m_hasNotifySignal(o.m_hasNotifySignal)
+ : m_objectDebugId(o.m_objectDebugId), m_name(o.m_name), m_value(o.m_value),
+ m_valueTypeName(o.m_valueTypeName), m_binding(o.m_binding),
+ m_hasNotifySignal(o.m_hasNotifySignal)
{
}
diff --git a/src/declarative/debugger/qdeclarativedebug_p.h b/src/declarative/debugger/qdeclarativeenginedebug_p.h
index f822637eb4..d98e4e875e 100644
--- a/src/declarative/debugger/qdeclarativedebug_p.h
+++ b/src/declarative/debugger/qdeclarativeenginedebug_p.h
@@ -38,8 +38,20 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#ifndef QDECLARATIVEDEBUG_H
-#define QDECLARATIVEDEBUG_H
+
+#ifndef QDECLARATIVEENGINEDEBUG_H
+#define QDECLARATIVEENGINEDEBUG_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
#include <QtCore/qobject.h>
#include <QtCore/qurl.h>
@@ -69,37 +81,38 @@ class QDeclarativeDebugEngineReference;
class QDeclarativeEngineDebugPrivate;
class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeEngineDebug : public QObject
{
-Q_OBJECT
+ Q_OBJECT
public:
enum Status { NotConnected, Unavailable, Enabled };
explicit QDeclarativeEngineDebug(QDeclarativeDebugConnection *, QObject * = 0);
+ ~QDeclarativeEngineDebug();
Status status() const;
QDeclarativeDebugPropertyWatch *addWatch(const QDeclarativeDebugPropertyReference &,
- QObject *parent = 0);
+ QObject *parent = 0);
QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugContextReference &, const QString &,
- QObject *parent = 0);
+ QObject *parent = 0);
QDeclarativeDebugObjectExpressionWatch *addWatch(const QDeclarativeDebugObjectReference &, const QString &,
- QObject *parent = 0);
+ QObject *parent = 0);
QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugObjectReference &,
- QObject *parent = 0);
+ QObject *parent = 0);
QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugFileReference &,
- QObject *parent = 0);
+ QObject *parent = 0);
void removeWatch(QDeclarativeDebugWatch *watch);
QDeclarativeDebugEnginesQuery *queryAvailableEngines(QObject *parent = 0);
QDeclarativeDebugRootContextQuery *queryRootContexts(const QDeclarativeDebugEngineReference &,
- QObject *parent = 0);
- QDeclarativeDebugObjectQuery *queryObject(const QDeclarativeDebugObjectReference &,
- QObject *parent = 0);
- QDeclarativeDebugObjectQuery *queryObjectRecursive(const QDeclarativeDebugObjectReference &,
+ QObject *parent = 0);
+ QDeclarativeDebugObjectQuery *queryObject(const QDeclarativeDebugObjectReference &,
QObject *parent = 0);
- QDeclarativeDebugExpressionQuery *queryExpressionResult(int objectDebugId,
- const QString &expr,
- QObject *parent = 0);
+ QDeclarativeDebugObjectQuery *queryObjectRecursive(const QDeclarativeDebugObjectReference &,
+ QObject *parent = 0);
+ QDeclarativeDebugExpressionQuery *queryExpressionResult(int objectDebugId,
+ const QString &expr,
+ QObject *parent = 0);
bool setBindingForObject(int objectDebugId, const QString &propertyName,
const QVariant &bindingExpression, bool isLiteralValue,
QString source = QString(), int line = -1);
@@ -116,7 +129,7 @@ private:
class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugWatch : public QObject
{
-Q_OBJECT
+ Q_OBJECT
public:
enum State { Waiting, Active, Inactive, Dead };
@@ -175,15 +188,13 @@ private:
class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugQuery : public QObject
{
-Q_OBJECT
+ Q_OBJECT
public:
enum State { Waiting, Error, Completed };
State state() const;
bool isWaiting() const;
-// bool waitUntilCompleted();
-
Q_SIGNALS:
void stateChanged(QDeclarativeDebugQuery::State);
@@ -314,7 +325,7 @@ private:
class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEnginesQuery : public QDeclarativeDebugQuery
{
-Q_OBJECT
+ Q_OBJECT
public:
virtual ~QDeclarativeDebugEnginesQuery();
QList<QDeclarativeDebugEngineReference> engines() const;
@@ -329,7 +340,7 @@ private:
class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugRootContextQuery : public QDeclarativeDebugQuery
{
-Q_OBJECT
+ Q_OBJECT
public:
virtual ~QDeclarativeDebugRootContextQuery();
QDeclarativeDebugContextReference rootContext() const;
@@ -344,7 +355,7 @@ private:
class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectQuery : public QDeclarativeDebugQuery
{
-Q_OBJECT
+ Q_OBJECT
public:
virtual ~QDeclarativeDebugObjectQuery();
QDeclarativeDebugObjectReference object() const;
@@ -360,7 +371,7 @@ private:
class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugExpressionQuery : public QDeclarativeDebugQuery
{
-Q_OBJECT
+ Q_OBJECT
public:
virtual ~QDeclarativeDebugExpressionQuery();
QVariant expression() const;
@@ -384,4 +395,4 @@ Q_DECLARE_METATYPE(QDeclarativeDebugPropertyReference)
QT_END_HEADER
-#endif // QDECLARATIVEDEBUG_H
+#endif // QDECLARATIVEENGINEDEBUG_H
diff --git a/src/declarative/debugger/qdeclarativeenginedebugservice.cpp b/src/declarative/debugger/qdeclarativeenginedebugservice.cpp
new file mode 100644
index 0000000000..9841f8778e
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativeenginedebugservice.cpp
@@ -0,0 +1,747 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "private/qdeclarativeenginedebugservice_p.h"
+
+#include "private/qdeclarativeboundsignal_p.h"
+#include "qdeclarativeengine.h"
+#include "private/qdeclarativemetatype_p.h"
+#include "qdeclarativeproperty.h"
+#include "private/qdeclarativeproperty_p.h"
+#include "private/qdeclarativebinding_p.h"
+#include "private/qdeclarativecontext_p.h"
+#include "private/qdeclarativewatcher_p.h"
+#include "private/qdeclarativevaluetype_p.h"
+#include "private/qdeclarativevmemetaobject_p.h"
+#include "private/qdeclarativeexpression_p.h"
+#include "private/qdeclarativepropertychanges_p.h"
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qmetaobject.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_GLOBAL_STATIC(QDeclarativeEngineDebugService, qmlEngineDebugService);
+
+QDeclarativeEngineDebugService *QDeclarativeEngineDebugService::instance()
+{
+ return qmlEngineDebugService();
+}
+
+QDeclarativeEngineDebugService::QDeclarativeEngineDebugService(QObject *parent)
+ : QDeclarativeDebugService(QLatin1String("QDeclarativeEngine"), parent),
+ m_watch(new QDeclarativeWatcher(this))
+{
+ QObject::connect(m_watch, SIGNAL(propertyChanged(int,int,QMetaProperty,QVariant)),
+ this, SLOT(propertyChanged(int,int,QMetaProperty,QVariant)));
+}
+
+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;
+ return ds;
+}
+
+QDataStream &operator>>(QDataStream &ds,
+ QDeclarativeEngineDebugService::QDeclarativeObjectData &data)
+{
+ ds >> data.url >> data.lineNumber >> data.columnNumber >> data.idString
+ >> data.objectName >> data.objectType >> data.objectId >> data.contextId;
+ return ds;
+}
+
+QDataStream &operator<<(QDataStream &ds,
+ const QDeclarativeEngineDebugService::QDeclarativeObjectProperty &data)
+{
+ ds << (int)data.type << data.name << data.value << data.valueTypeName
+ << data.binding << data.hasNotifySignal;
+ return ds;
+}
+
+QDataStream &operator>>(QDataStream &ds,
+ QDeclarativeEngineDebugService::QDeclarativeObjectProperty &data)
+{
+ int type;
+ ds >> type >> data.name >> data.value >> data.valueTypeName
+ >> data.binding >> data.hasNotifySignal;
+ data.type = (QDeclarativeEngineDebugService::QDeclarativeObjectProperty::Type)type;
+ return ds;
+}
+
+static inline bool isSignalPropertyName(const QString &signalName)
+{
+ // see QmlCompiler::isSignalPropertyName
+ return signalName.length() >= 3 && signalName.startsWith(QLatin1String("on")) &&
+ signalName.at(2).isLetter() && signalName.at(2).isUpper();
+}
+
+static bool hasValidSignal(QObject *object, const QString &propertyName)
+{
+ if (!isSignalPropertyName(propertyName))
+ return false;
+
+ QString signalName = propertyName.mid(2);
+ signalName[0] = signalName.at(0).toLower();
+
+ int sigIdx = QDeclarativePropertyPrivate::findSignalByName(object->metaObject(), signalName.toLatin1()).methodIndex();
+
+ if (sigIdx == -1)
+ return false;
+
+ return true;
+}
+
+QDeclarativeEngineDebugService::QDeclarativeObjectProperty
+QDeclarativeEngineDebugService::propertyData(QObject *obj, int propIdx)
+{
+ QDeclarativeObjectProperty rv;
+
+ QMetaProperty prop = obj->metaObject()->property(propIdx);
+
+ rv.type = QDeclarativeObjectProperty::Unknown;
+ rv.valueTypeName = QString::fromUtf8(prop.typeName());
+ rv.name = QString::fromUtf8(prop.name());
+ rv.hasNotifySignal = prop.hasNotifySignal();
+ QDeclarativeAbstractBinding *binding =
+ QDeclarativePropertyPrivate::binding(QDeclarativeProperty(obj, rv.name));
+ if (binding)
+ rv.binding = binding->expression();
+
+ if (QDeclarativeValueTypeFactory::isValueType(prop.userType())) {
+ rv.type = QDeclarativeObjectProperty::Basic;
+ } else if (QDeclarativeMetaType::isQObject(prop.userType())) {
+ rv.type = QDeclarativeObjectProperty::Object;
+ } else if (QDeclarativeMetaType::isList(prop.userType())) {
+ rv.type = QDeclarativeObjectProperty::List;
+ }
+
+ QVariant value;
+ if (rv.type != QDeclarativeObjectProperty::Unknown && prop.userType() != 0) {
+ value = prop.read(obj);
+ }
+ rv.value = valueContents(value);
+
+ return rv;
+}
+
+QVariant QDeclarativeEngineDebugService::valueContents(const QVariant &value) const
+{
+ int userType = value.userType();
+
+ if (value.type() == QVariant::List) {
+ QVariantList contents;
+ QVariantList list = value.toList();
+ int count = list.size();
+ for (int i = 0; i < count; i++)
+ contents << valueContents(list.at(i));
+ return contents;
+ }
+
+ if (QDeclarativeValueTypeFactory::isValueType(userType))
+ return value;
+
+ if (QDeclarativeMetaType::isQObject(userType)) {
+ QObject *o = QDeclarativeMetaType::toQObject(value);
+ if (o) {
+ QString name = o->objectName();
+ if (name.isEmpty())
+ name = QLatin1String("<unnamed object>");
+ return name;
+ }
+ }
+
+ return QLatin1String("<unknown value>");
+}
+
+void QDeclarativeEngineDebugService::buildObjectDump(QDataStream &message,
+ QObject *object, bool recur, bool dumpProperties)
+{
+ message << objectData(object);
+
+ QObjectList children = object->children();
+
+ int childrenCount = children.count();
+ for (int ii = 0; ii < children.count(); ++ii) {
+ if (qobject_cast<QDeclarativeContext*>(children[ii]) || QDeclarativeBoundSignal::cast(children[ii]))
+ --childrenCount;
+ }
+
+ message << childrenCount << recur;
+
+ QList<QDeclarativeObjectProperty> fakeProperties;
+
+ 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;
+ QDeclarativeExpression *expr = signal->expression();
+ if (expr) {
+ prop.value = expr->expression();
+ QObject *scope = expr->scopeObject();
+ if (scope) {
+ QString sig = QLatin1String(scope->metaObject()->method(signal->index()).signature());
+ int lparen = sig.indexOf(QLatin1Char('('));
+ if (lparen >= 0) {
+ QString methodName = sig.mid(0, lparen);
+ prop.name = QLatin1String("on") + methodName[0].toUpper()
+ + methodName.mid(1);
+ }
+ }
+ }
+ 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)
+ message << propertyData(object, propertyIndexes.at(ii));
+
+ for (int ii = 0; ii < fakeProperties.count(); ++ii)
+ message << fakeProperties[ii];
+}
+
+void QDeclarativeEngineDebugService::prepareDeferredObjects(QObject *obj)
+{
+ qmlExecuteDeferred(obj);
+
+ QObjectList children = obj->children();
+ for (int ii = 0; ii < children.count(); ++ii) {
+ QObject *child = children.at(ii);
+ prepareDeferredObjects(child);
+ }
+
+}
+
+void QDeclarativeEngineDebugService::buildObjectList(QDataStream &message, QDeclarativeContext *ctxt)
+{
+ QDeclarativeContextData *p = QDeclarativeContextData::get(ctxt);
+
+ QString ctxtName = ctxt->objectName();
+ int ctxtId = QDeclarativeDebugService::idForObject(ctxt);
+
+ message << ctxtName << ctxtId;
+
+ int count = 0;
+
+ QDeclarativeContextData *child = p->childContexts;
+ while (child) {
+ ++count;
+ child = child->nextChild;
+ }
+
+ message << count;
+
+ child = p->childContexts;
+ while (child) {
+ buildObjectList(message, child->asQDeclarativeContext());
+ child = child->nextChild;
+ }
+
+ // Clean deleted objects
+ QDeclarativeContextPrivate *ctxtPriv = QDeclarativeContextPrivate::get(ctxt);
+ for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) {
+ if (!ctxtPriv->instances.at(ii)) {
+ ctxtPriv->instances.removeAt(ii);
+ --ii;
+ }
+ }
+
+ message << ctxtPriv->instances.count();
+ for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) {
+ message << objectData(ctxtPriv->instances.at(ii));
+ }
+}
+
+void QDeclarativeEngineDebugService::buildStatesList(QDeclarativeContext *ctxt, bool cleanList=false)
+{
+ if (cleanList)
+ m_allStates.clear();
+
+ QDeclarativeContextPrivate *ctxtPriv = QDeclarativeContextPrivate::get(ctxt);
+ for (int ii = 0; ii < ctxtPriv->instances.count(); ++ii) {
+ buildStatesList(ctxtPriv->instances.at(ii));
+ }
+
+ QDeclarativeContextData *child = QDeclarativeContextData::get(ctxt)->childContexts;
+ while (child) {
+ buildStatesList(child->asQDeclarativeContext());
+ child = child->nextChild;
+ }
+}
+
+void QDeclarativeEngineDebugService::buildStatesList(QObject *obj)
+{
+ if (QDeclarativeState *state = qobject_cast<QDeclarativeState *>(obj)) {
+ m_allStates.append(state);
+ }
+
+ QObjectList children = obj->children();
+ for (int ii = 0; ii < children.count(); ++ii) {
+ buildStatesList(children.at(ii));
+ }
+}
+
+QDeclarativeEngineDebugService::QDeclarativeObjectData
+QDeclarativeEngineDebugService::objectData(QObject *object)
+{
+ QDeclarativeData *ddata = QDeclarativeData::get(object);
+ QDeclarativeObjectData rv;
+ if (ddata && ddata->outerContext) {
+ rv.url = ddata->outerContext->url;
+ rv.lineNumber = ddata->lineNumber;
+ rv.columnNumber = ddata->columnNumber;
+ } else {
+ rv.lineNumber = -1;
+ rv.columnNumber = -1;
+ }
+
+ QDeclarativeContext *context = qmlContext(object);
+ if (context) {
+ QDeclarativeContextData *cdata = QDeclarativeContextData::get(context);
+ if (cdata)
+ rv.idString = cdata->findObjectId(object);
+ }
+
+ rv.objectName = object->objectName();
+ rv.objectId = QDeclarativeDebugService::idForObject(object);
+ rv.contextId = QDeclarativeDebugService::idForObject(qmlContext(object));
+
+ QDeclarativeType *type = QDeclarativeMetaType::qmlType(object->metaObject());
+ if (type) {
+ QString typeName = QLatin1String(type->qmlTypeName());
+ int lastSlash = typeName.lastIndexOf(QLatin1Char('/'));
+ rv.objectType = lastSlash < 0 ? typeName : typeName.mid(lastSlash+1);
+ } else {
+ rv.objectType = QString::fromUtf8(object->metaObject()->className());
+ int marker = rv.objectType.indexOf(QLatin1String("_QMLTYPE_"));
+ if (marker != -1)
+ rv.objectType = rv.objectType.left(marker);
+ }
+
+ return rv;
+}
+
+void QDeclarativeEngineDebugService::messageReceived(const QByteArray &message)
+{
+ QDataStream ds(message);
+
+ QByteArray type;
+ ds >> type;
+
+ 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();
+
+ for (int ii = 0; ii < m_engines.count(); ++ii) {
+ QDeclarativeEngine *engine = m_engines.at(ii);
+
+ 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;
+
+ QDeclarativeEngine *engine =
+ qobject_cast<QDeclarativeEngine *>(QDeclarativeDebugService::objectForId(engineId));
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("LIST_OBJECTS_R") << queryId;
+
+ if (engine) {
+ buildObjectList(rs, engine->rootContext());
+ 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;
+
+ QObject *object = QDeclarativeDebugService::objectForId(objectId);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+ rs << QByteArray("FETCH_OBJECT_R") << queryId;
+
+ if (object) {
+ if (recurse)
+ prepareDeferredObjects(object);
+ buildObjectDump(rs, object, recurse, dumpProperties);
+ }
+
+ sendMessage(reply);
+ } else if (type == "WATCH_OBJECT") {
+ int queryId;
+ int objectId;
+
+ ds >> queryId >> 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;
+ 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;
+ 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;
+
+ QObject *object = QDeclarativeDebugService::objectForId(objectId);
+ QDeclarativeContext *context = qmlContext(object);
+ QVariant result;
+ if (object && context) {
+ QDeclarativeExpression exprObj(context, object, expr);
+ bool undefined = false;
+ QVariant value = exprObj.evaluate(&undefined);
+ if (undefined)
+ result = QLatin1String("<undefined>");
+ else
+ result = valueContents(value);
+ } else {
+ 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;
+ QVariant expr;
+ bool isLiteralValue;
+ QString filename;
+ int line;
+ ds >> objectId >> propertyName >> expr >> isLiteralValue;
+ if (!ds.atEnd()) { // backward compatibility from 2.1, 2.2
+ ds >> filename >> line;
+ }
+ setBinding(objectId, propertyName, expr, isLiteralValue, filename, line);
+ } else if (type == "RESET_BINDING") {
+ int objectId;
+ QString propertyName;
+ ds >> objectId >> propertyName;
+ resetBinding(objectId, propertyName);
+ } else if (type == "SET_METHOD_BODY") {
+ int objectId;
+ QString methodName;
+ QString methodBody;
+ ds >> objectId >> methodName >> methodBody;
+ setMethodBody(objectId, methodName, methodBody);
+ }
+}
+
+void QDeclarativeEngineDebugService::setBinding(int objectId,
+ const QString &propertyName,
+ const QVariant &expression,
+ bool isLiteralValue,
+ QString filename,
+ int line)
+{
+ QObject *object = objectForId(objectId);
+ QDeclarativeContext *context = qmlContext(object);
+
+ if (object && context) {
+ QDeclarativeProperty property(object, propertyName, context);
+ if (property.isValid()) {
+
+ bool inBaseState = true;
+
+ foreach(QWeakPointer<QDeclarativeState> statePointer, m_allStates) {
+ if (QDeclarativeState *state = statePointer.data()) {
+ // here we assume that the revert list on itself defines the base state
+ if (state->isStateActive() && state->containsPropertyInRevertList(object, propertyName)) {
+ inBaseState = false;
+
+ QDeclarativeBinding *newBinding = 0;
+ if (!isLiteralValue) {
+ newBinding = new QDeclarativeBinding(expression.toString(), object, context);
+ newBinding->setTarget(property);
+ newBinding->setNotifyOnValueChanged(true);
+ newBinding->setSourceLocation(filename, line);
+ }
+
+ state->changeBindingInRevertList(object, propertyName, newBinding);
+
+ if (isLiteralValue)
+ state->changeValueInRevertList(object, propertyName, expression);
+ }
+ }
+ }
+
+ if (inBaseState) {
+ if (isLiteralValue) {
+ property.write(expression);
+ } else if (hasValidSignal(object, propertyName)) {
+ QDeclarativeExpression *declarativeExpression = new QDeclarativeExpression(context, object, expression.toString());
+ QDeclarativePropertyPrivate::setSignalExpression(property, declarativeExpression);
+ declarativeExpression->setSourceLocation(filename, line);
+ } else if (property.isProperty()) {
+ QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context);
+ binding->setTarget(property);
+ binding->setSourceLocation(filename, line);
+ binding->setNotifyOnValueChanged(true);
+ QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, binding);
+ if (oldBinding)
+ oldBinding->destroy();
+ binding->update();
+ } else {
+ qWarning() << "QDeclarativeEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object;
+ }
+ }
+
+ } else {
+ // not a valid property
+ if (QDeclarativePropertyChanges *propertyChanges = qobject_cast<QDeclarativePropertyChanges *>(object)) {
+ if (isLiteralValue) {
+ propertyChanges->changeValue(propertyName, expression);
+ } else {
+ propertyChanges->changeExpression(propertyName, expression.toString());
+ }
+ } else {
+ qWarning() << "QDeclarativeEngineDebugService::setBinding: unable to set property" << propertyName << "on object" << object;
+ }
+ }
+ }
+}
+
+void QDeclarativeEngineDebugService::resetBinding(int objectId, const QString &propertyName)
+{
+ QObject *object = objectForId(objectId);
+ QDeclarativeContext *context = qmlContext(object);
+
+ if (object && context) {
+ if (object->property(propertyName.toLatin1()).isValid()) {
+ QDeclarativeProperty property(object, propertyName);
+ QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::binding(property);
+ if (oldBinding) {
+ QDeclarativeAbstractBinding *oldBinding = QDeclarativePropertyPrivate::setBinding(property, 0);
+ if (oldBinding)
+ oldBinding->destroy();
+ }
+ if (property.isResettable()) {
+ // Note: this will reset the property in any case, without regard to states
+ // Right now almost no QDeclarativeItem has reset methods for its properties (with the
+ // notable exception of QDeclarativeAnchors), so this is not a big issue
+ // later on, setBinding does take states into account
+ property.reset();
+ } else {
+ // overwrite with default value
+ if (QDeclarativeType *objType = QDeclarativeMetaType::qmlType(object->metaObject())) {
+ if (QObject *emptyObject = objType->create()) {
+ if (emptyObject->property(propertyName.toLatin1()).isValid()) {
+ QVariant defaultValue = QDeclarativeProperty(emptyObject, propertyName).read();
+ if (defaultValue.isValid()) {
+ setBinding(objectId, propertyName, defaultValue, true);
+ }
+ }
+ delete emptyObject;
+ }
+ }
+ }
+ } else if (hasValidSignal(object, propertyName)) {
+ QDeclarativeProperty property(object, propertyName, context);
+ QDeclarativePropertyPrivate::setSignalExpression(property, 0);
+ } else {
+ if (QDeclarativePropertyChanges *propertyChanges = qobject_cast<QDeclarativePropertyChanges *>(object)) {
+ propertyChanges->removeProperty(propertyName);
+ }
+ }
+ }
+}
+
+void QDeclarativeEngineDebugService::setMethodBody(int objectId, const QString &method, const QString &body)
+{
+ QObject *object = objectForId(objectId);
+ QDeclarativeContext *context = qmlContext(object);
+ if (!object || !context || !context->engine())
+ return;
+ QDeclarativeContextData *contextData = QDeclarativeContextData::get(context);
+ if (!contextData)
+ return;
+
+ QDeclarativePropertyCache::Data dummy;
+ QDeclarativePropertyCache::Data *prop =
+ QDeclarativePropertyCache::property(context->engine(), object, method, dummy);
+
+ if (!prop || !prop->isVMEFunction())
+ return;
+
+ QMetaMethod metaMethod = object->metaObject()->method(prop->coreIndex);
+ QList<QByteArray> paramNames = metaMethod.parameterNames();
+
+ QString paramStr;
+ for (int ii = 0; ii < paramNames.count(); ++ii) {
+ if (ii != 0) paramStr.append(QLatin1String(","));
+ paramStr.append(QString::fromUtf8(paramNames.at(ii)));
+ }
+
+ QString jsfunction = QLatin1String("(function ") + method + QLatin1String("(") + paramStr +
+ QLatin1String(") {");
+ jsfunction += body;
+ jsfunction += QLatin1String("\n})");
+
+ QDeclarativeVMEMetaObject *vmeMetaObject =
+ static_cast<QDeclarativeVMEMetaObject*>(QObjectPrivate::get(object)->metaObject);
+ Q_ASSERT(vmeMetaObject); // the fact we found the property above should guarentee this
+
+ int lineNumber = vmeMetaObject->vmeMethodLineNumber(prop->coreIndex);
+ vmeMetaObject->setVmeMethod(prop->coreIndex, QDeclarativeExpressionPrivate::evalFunction(contextData, object, jsfunction, contextData->url.toString(), lineNumber));
+}
+
+void QDeclarativeEngineDebugService::propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value)
+{
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+
+ rs << QByteArray("UPDATE_WATCH") << id << objectId << QByteArray(property.name()) << valueContents(value);
+
+ sendMessage(reply);
+}
+
+void QDeclarativeEngineDebugService::addEngine(QDeclarativeEngine *engine)
+{
+ Q_ASSERT(engine);
+ Q_ASSERT(!m_engines.contains(engine));
+
+ m_engines.append(engine);
+}
+
+void QDeclarativeEngineDebugService::remEngine(QDeclarativeEngine *engine)
+{
+ Q_ASSERT(engine);
+ Q_ASSERT(m_engines.contains(engine));
+
+ m_engines.removeAll(engine);
+}
+
+void QDeclarativeEngineDebugService::objectCreated(QDeclarativeEngine *engine, QObject *object)
+{
+ Q_ASSERT(engine);
+ Q_ASSERT(m_engines.contains(engine));
+
+ int engineId = QDeclarativeDebugService::idForObject(engine);
+ int objectId = QDeclarativeDebugService::idForObject(object);
+
+ QByteArray reply;
+ QDataStream rs(&reply, QIODevice::WriteOnly);
+
+ rs << QByteArray("OBJECT_CREATED") << engineId << objectId;
+ sendMessage(reply);
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qdeclarativeenginedebugservice_p.h b/src/declarative/debugger/qdeclarativeenginedebugservice_p.h
new file mode 100644
index 0000000000..3674b83fe7
--- /dev/null
+++ b/src/declarative/debugger/qdeclarativeenginedebugservice_p.h
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEENGINEDEBUGSERVICE_P_H
+#define QDECLARATIVEENGINEDEBUGSERVICE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qdeclarativedebugservice_p.h>
+
+#include <QtCore/qurl.h>
+#include <QtCore/qvariant.h>
+#include <QWeakPointer>
+
+QT_BEGIN_NAMESPACE
+
+class QDeclarativeEngine;
+class QDeclarativeContext;
+class QDeclarativeWatcher;
+class QDataStream;
+class QDeclarativeState;
+
+class QDeclarativeEngineDebugService : public QDeclarativeDebugService
+{
+ Q_OBJECT
+public:
+ QDeclarativeEngineDebugService(QObject * = 0);
+
+ struct QDeclarativeObjectData {
+ QUrl url;
+ int lineNumber;
+ int columnNumber;
+ QString idString;
+ QString objectName;
+ QString objectType;
+ int objectId;
+ int contextId;
+ };
+
+ struct QDeclarativeObjectProperty {
+ enum Type { Unknown, Basic, Object, List, SignalProperty };
+ Type type;
+ QString name;
+ QVariant value;
+ QString valueTypeName;
+ QString binding;
+ bool hasNotifySignal;
+ };
+
+ void addEngine(QDeclarativeEngine *);
+ void remEngine(QDeclarativeEngine *);
+ void objectCreated(QDeclarativeEngine *, QObject *);
+
+ static QDeclarativeEngineDebugService *instance();
+
+protected:
+ virtual void messageReceived(const QByteArray &);
+
+private Q_SLOTS:
+ void propertyChanged(int id, int objectId, const QMetaProperty &property, const QVariant &value);
+
+private:
+ void prepareDeferredObjects(QObject *);
+ void buildObjectList(QDataStream &, QDeclarativeContext *);
+ void buildObjectDump(QDataStream &, QObject *, bool, bool);
+ void buildStatesList(QDeclarativeContext *, bool);
+ void buildStatesList(QObject *obj);
+ QDeclarativeObjectData objectData(QObject *);
+ QDeclarativeObjectProperty propertyData(QObject *, int);
+ QVariant valueContents(const QVariant &defaultValue) const;
+ void setBinding(int objectId, const QString &propertyName, const QVariant &expression, bool isLiteralValue, QString filename = QString(), int line = -1);
+ void resetBinding(int objectId, const QString &propertyName);
+ void setMethodBody(int objectId, const QString &method, const QString &body);
+
+ QList<QDeclarativeEngine *> m_engines;
+ QDeclarativeWatcher *m_watch;
+ QList<QWeakPointer<QDeclarativeState> > m_allStates;
+};
+Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugService::QDeclarativeObjectData &);
+Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugService::QDeclarativeObjectData &);
+Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator<<(QDataStream &, const QDeclarativeEngineDebugService::QDeclarativeObjectProperty &);
+Q_DECLARATIVE_PRIVATE_EXPORT QDataStream &operator>>(QDataStream &, QDeclarativeEngineDebugService::QDeclarativeObjectProperty &);
+
+QT_END_NAMESPACE
+
+#endif // QDECLARATIVEENGINEDEBUGSERVICE_P_H
+
diff --git a/src/declarative/debugger/qdeclarativeinspectorinterface_p.h b/src/declarative/debugger/qdeclarativeinspectorinterface_p.h
index aa29d6807e..d0d9f44d7b 100644
--- a/src/declarative/debugger/qdeclarativeinspectorinterface_p.h
+++ b/src/declarative/debugger/qdeclarativeinspectorinterface_p.h
@@ -39,8 +39,19 @@
**
****************************************************************************/
-#ifndef QDECLARATIVEOBSERVERINTERFACE_H
-#define QDECLARATIVEOBSERVERINTERFACE_H
+#ifndef QDECLARATIVEINSPECTORINTERFACE_H
+#define QDECLARATIVEINSPECTORINTERFACE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
#include <QtDeclarative/private/qdeclarativeglobal_p.h>
@@ -66,4 +77,4 @@ QT_END_NAMESPACE
QT_END_HEADER
-#endif // QDECLARATIVEOBSERVERINTERFACE_H
+#endif // QDECLARATIVEINSPECTORINTERFACE_H
diff --git a/src/declarative/debugger/qdeclarativeinspectorservice_p.h b/src/declarative/debugger/qdeclarativeinspectorservice_p.h
index db94103210..98b2e9deeb 100644
--- a/src/declarative/debugger/qdeclarativeinspectorservice_p.h
+++ b/src/declarative/debugger/qdeclarativeinspectorservice_p.h
@@ -39,8 +39,19 @@
**
****************************************************************************/
-#ifndef QDECLARATIVEOBSERVERSERVICE_H
-#define QDECLARATIVEOBSERVERSERVICE_H
+#ifndef QDECLARATIVEINSPECTORSERVICE_H
+#define QDECLARATIVEINSPECTORSERVICE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
#include "private/qdeclarativedebugservice_p.h"
#include <private/qdeclarativeglobal_p.h>
@@ -87,4 +98,4 @@ QT_END_NAMESPACE
QT_END_HEADER
-#endif // QDECLARATIVEOBSERVERSERVICE_H
+#endif // QDECLARATIVEINSPECTORSERVICE_H
diff --git a/src/declarative/debugger/qpacketprotocol.cpp b/src/declarative/debugger/qpacketprotocol.cpp
index 9caaa79011..9b95d06e1e 100644
--- a/src/declarative/debugger/qpacketprotocol.cpp
+++ b/src/declarative/debugger/qpacketprotocol.cpp
@@ -41,12 +41,12 @@
#include "private/qpacketprotocol_p.h"
-#include <QBuffer>
-#include <QElapsedTimer>
+#include <QtCore/QBuffer>
+#include <QtCore/QElapsedTimer>
QT_BEGIN_NAMESPACE
-#define MAX_PACKET_SIZE 0x7FFFFFFF
+static const unsigned int MAX_PACKET_SIZE = 0x7FFFFFFF;
/*!
\class QPacketProtocol
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE
\brief The QPacketProtocol class encapsulates communicating discrete packets
across fragmented IO channels, such as TCP sockets.
- QPacketProtocol makes it simple to send arbitrary sized data "packets" across
+ QPacketProtocol makes it simple to send arbitrary sized data "packets" across
fragmented transports such as TCP and UDP.
As transmission boundaries are not respected, sending packets over protocols
@@ -111,11 +111,11 @@ QT_BEGIN_NAMESPACE
class QPacketProtocolPrivate : public QObject
{
-Q_OBJECT
+ Q_OBJECT
public:
- QPacketProtocolPrivate(QPacketProtocol * parent, QIODevice * _dev)
- : QObject(parent), inProgressSize(-1), maxPacketSize(MAX_PACKET_SIZE),
- waitingForPacket(false), dev(_dev)
+ QPacketProtocolPrivate(QPacketProtocol *parent, QIODevice *_dev)
+ : QObject(parent), inProgressSize(-1), maxPacketSize(MAX_PACKET_SIZE),
+ waitingForPacket(false), dev(_dev)
{
Q_ASSERT(4 == sizeof(qint32));
@@ -150,8 +150,8 @@ public Q_SLOTS:
{
Q_ASSERT(!sendingPackets.isEmpty());
- while(bytes) {
- if(sendingPackets.at(0) > bytes) {
+ while (bytes) {
+ if (sendingPackets.at(0) > bytes) {
sendingPackets[0] -= bytes;
bytes = 0;
} else {
@@ -214,15 +214,15 @@ public:
qint32 inProgressSize;
qint32 maxPacketSize;
bool waitingForPacket;
- QIODevice * dev;
+ QIODevice *dev;
};
/*!
Construct a QPacketProtocol instance that works on \a dev with the
specified \a parent.
*/
-QPacketProtocol::QPacketProtocol(QIODevice * dev, QObject * parent)
-: QObject(parent), d(new QPacketProtocolPrivate(this, dev))
+QPacketProtocol::QPacketProtocol(QIODevice *dev, QObject *parent)
+ : QObject(parent), d(new QPacketProtocolPrivate(this, dev))
{
Q_ASSERT(dev);
}
@@ -236,7 +236,7 @@ QPacketProtocol::~QPacketProtocol()
/*!
Returns the maximum packet size allowed. By default this is
- 2,147,483,647 bytes.
+ 2,147,483,647 bytes.
If a packet claiming to be larger than the maximum packet size is received,
the QPacketProtocol::invalidPacket() signal is emitted.
@@ -255,7 +255,7 @@ qint32 QPacketProtocol::maximumPacketSize() const
*/
qint32 QPacketProtocol::setMaximumPacketSize(qint32 max)
{
- if(max > (signed)sizeof(qint32))
+ if (max > (signed)sizeof(qint32))
d->maxPacketSize = max;
return d->maxPacketSize;
}
@@ -267,7 +267,7 @@ qint32 QPacketProtocol::setMaximumPacketSize(qint32 max)
protocol.send() << "Hello world" << 123;
\endcode
- will send a packet containing "Hello world" and 123. To construct more
+ will send a packet containing "Hello world" and 123. To construct more
complex packets, explicitly construct a QPacket instance.
*/
QPacketAutoSend QPacketProtocol::send()
@@ -282,7 +282,7 @@ QPacketAutoSend QPacketProtocol::send()
*/
void QPacketProtocol::send(const QPacket & p)
{
- if(p.b.isEmpty())
+ if (p.b.isEmpty())
return; // We don't send empty packets
qint64 sendSize = p.b.size() + sizeof(qint32);
@@ -317,7 +317,7 @@ void QPacketProtocol::clear()
*/
QPacket QPacketProtocol::read()
{
- if(0 == d->packets.count())
+ if (0 == d->packets.count())
return QPacket();
QPacket rv(d->packets.at(0));
@@ -370,7 +370,7 @@ bool QPacketProtocol::waitForReadyRead(int msecs)
/*!
Return the QIODevice passed to the QPacketProtocol constructor.
*/
-QIODevice * QPacketProtocol::device()
+QIODevice *QPacketProtocol::device()
{
return d->dev;
}
@@ -433,8 +433,8 @@ QIODevice * QPacketProtocol::device()
\endcode
Only packets returned from QPacketProtocol::read() may be read from. QPacket
- instances constructed by directly by applications are for transmission only
- and are considered "write only". Attempting to read data from them will
+ instances constructed by directly by applications are for transmission only
+ and are considered "write only". Attempting to read data from them will
result in undefined behavior.
\ingroup io
@@ -445,7 +445,7 @@ QIODevice * QPacketProtocol::device()
Constructs an empty write-only packet.
*/
QPacket::QPacket()
-: QDataStream(), buf(0)
+ : QDataStream(), buf(0)
{
buf = new QBuffer(&b);
buf->open(QIODevice::WriteOnly);
@@ -458,7 +458,7 @@ QPacket::QPacket()
*/
QPacket::~QPacket()
{
- if(buf) {
+ if (buf) {
delete buf;
buf = 0;
}
@@ -469,7 +469,7 @@ QPacket::~QPacket()
two packets are otherwise independent.
*/
QPacket::QPacket(const QPacket & other)
-: QDataStream(), b(other.b), buf(0)
+ : QDataStream(), b(other.b), buf(0)
{
buf = new QBuffer(&b);
buf->open(other.buf->openMode());
@@ -480,7 +480,7 @@ QPacket::QPacket(const QPacket & other)
\internal
*/
QPacket::QPacket(const QByteArray & ba)
-: QDataStream(), b(ba), buf(0)
+ : QDataStream(), b(ba), buf(0)
{
buf = new QBuffer(&b);
buf->open(QIODevice::ReadOnly);
@@ -534,14 +534,14 @@ void QPacket::clear()
\internal
*/
-QPacketAutoSend::QPacketAutoSend(QPacketProtocol * _p)
-: QPacket(), p(_p)
+QPacketAutoSend::QPacketAutoSend(QPacketProtocol *_p)
+ : QPacket(), p(_p)
{
}
QPacketAutoSend::~QPacketAutoSend()
{
- if(!b.isEmpty())
+ if (!b.isEmpty())
p->send(*this);
}
diff --git a/src/declarative/debugger/qpacketprotocol_p.h b/src/declarative/debugger/qpacketprotocol_p.h
index df3b170d17..5d9d820317 100644
--- a/src/declarative/debugger/qpacketprotocol_p.h
+++ b/src/declarative/debugger/qpacketprotocol_p.h
@@ -42,6 +42,17 @@
#ifndef QPACKETPROTOCOL_H
#define QPACKETPROTOCOL_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
#include <QtCore/qobject.h>
#include <QtCore/qdatastream.h>
@@ -61,9 +72,9 @@ class QPacketProtocolPrivate;
class Q_DECLARATIVE_PRIVATE_EXPORT QPacketProtocol : public QObject
{
-Q_OBJECT
+ Q_OBJECT
public:
- explicit QPacketProtocol(QIODevice * dev, QObject * parent = 0);
+ explicit QPacketProtocol(QIODevice *dev, QObject *parent = 0);
virtual ~QPacketProtocol();
qint32 maximumPacketSize() const;
@@ -79,7 +90,7 @@ public:
void clear();
- QIODevice * device();
+ QIODevice *device();
Q_SIGNALS:
void readyRead();
@@ -87,7 +98,7 @@ Q_SIGNALS:
void packetWritten();
private:
- QPacketProtocolPrivate * d;
+ QPacketProtocolPrivate *d;
};
@@ -104,9 +115,9 @@ public:
protected:
friend class QPacketProtocol;
- QPacket(const QByteArray & ba);
+ QPacket(const QByteArray &ba);
QByteArray b;
- QBuffer * buf;
+ QBuffer *buf;
};
class Q_DECLARATIVE_PRIVATE_EXPORT QPacketAutoSend : public QPacket
@@ -117,7 +128,7 @@ public:
private:
friend class QPacketProtocol;
QPacketAutoSend(QPacketProtocol *);
- QPacketProtocol * p;
+ QPacketProtocol *p;
};
QT_END_NAMESPACE
diff --git a/src/declarative/debugger/qv8debugservice.cpp b/src/declarative/debugger/qv8debugservice.cpp
index 7d3f45e35e..7729e5bdf6 100644
--- a/src/declarative/debugger/qv8debugservice.cpp
+++ b/src/declarative/debugger/qv8debugservice.cpp
@@ -56,7 +56,9 @@ Q_GLOBAL_STATIC(QV8DebugService, v8ServiceInstance)
void DebugMessageHandler(const v8::Debug::Message& message)
{
v8::DebugEvent event = message.GetEvent();
- if (event != v8::Break && event != v8::Exception && event != v8::AfterCompile) {
+
+ if (event != v8::Break && event != v8::Exception &&
+ event != v8::AfterCompile && event != v8::BeforeCompile) {
return;
}
@@ -65,7 +67,8 @@ void DebugMessageHandler(const v8::Debug::Message& message)
QV8DebugService *service = QV8DebugService::instance();
service->debugMessageHandler(response);
- if (event == v8::Break && !message.WillStartRunning()) {
+ if ((event == v8::Break || event == v8::Exception) &&
+ !message.WillStartRunning()) {
service->executionStopped();
} else if (event == v8::AfterCompile) {
service->appendSourcePath(response);