diff options
Diffstat (limited to 'src/declarative/debugger')
30 files changed, 0 insertions, 7048 deletions
diff --git a/src/declarative/debugger/debugger.pri b/src/declarative/debugger/debugger.pri deleted file mode 100644 index 8e29e9fdf6..0000000000 --- a/src/declarative/debugger/debugger.pri +++ /dev/null @@ -1,32 +0,0 @@ -SOURCES += \ - $$PWD/qpacketprotocol.cpp \ - $$PWD/qdeclarativedebugservice.cpp \ - $$PWD/qdeclarativedebugclient.cpp \ - $$PWD/qdeclarativeenginedebug.cpp \ - $$PWD/qdeclarativeprofilerservice.cpp \ - $$PWD/qdeclarativedebughelper.cpp \ - $$PWD/qdeclarativedebugserver.cpp \ - $$PWD/qdeclarativeinspectorservice.cpp \ - $$PWD/qv8debugservice.cpp \ - $$PWD/qv8profilerservice.cpp \ - $$PWD/qdeclarativeenginedebugservice.cpp \ - $$PWD/qdebugmessageservice.cpp - -HEADERS += \ - $$PWD/qpacketprotocol_p.h \ - $$PWD/qdeclarativedebugservice_p.h \ - $$PWD/qdeclarativedebugservice_p_p.h \ - $$PWD/qdeclarativedebugclient_p.h \ - $$PWD/qdeclarativeenginedebug_p.h \ - $$PWD/qdeclarativeprofilerservice_p.h \ - $$PWD/qdeclarativedebughelper_p.h \ - $$PWD/qdeclarativedebugserver_p.h \ - $$PWD/qdeclarativedebugserverconnection_p.h \ - $$PWD/qdeclarativedebugstatesdelegate_p.h \ - $$PWD/qdeclarativeinspectorservice_p.h \ - $$PWD/qdeclarativeinspectorinterface_p.h \ - $$PWD/qv8debugservice_p.h \ - $$PWD/qv8profilerservice_p.h \ - $$PWD/qdeclarativeenginedebugservice_p.h \ - $$PWD/qdeclarativedebug.h \ - $$PWD/qdebugmessageservice_p.h diff --git a/src/declarative/debugger/qdebugmessageservice.cpp b/src/declarative/debugger/qdebugmessageservice.cpp deleted file mode 100644 index 3f18a0fe4b..0000000000 --- a/src/declarative/debugger/qdebugmessageservice.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qdebugmessageservice_p.h" -#include "qdeclarativedebugservice_p_p.h" - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QDebugMessageService, declarativeDebugMessageService) - -void DebugMessageHandler(QtMsgType type, const QMessageLogContext &ctxt, - const char *buf) -{ - QDebugMessageService::instance()->sendDebugMessage(type, ctxt, buf); -} - -class QDebugMessageServicePrivate : public QDeclarativeDebugServicePrivate -{ -public: - QDebugMessageServicePrivate() - : oldMsgHandler(0) - , prevState(QDeclarativeDebugService::NotConnected) - { - } - - QMessageHandler oldMsgHandler; - QDeclarativeDebugService::State prevState; -}; - -QDebugMessageService::QDebugMessageService(QObject *parent) : - QDeclarativeDebugService(*(new QDebugMessageServicePrivate()), - QLatin1String("DebugMessages"), 2, parent) -{ - Q_D(QDebugMessageService); - - registerService(); - if (state() == Enabled) { - d->oldMsgHandler = qInstallMessageHandler(DebugMessageHandler); - d->prevState = Enabled; - } -} - -QDebugMessageService *QDebugMessageService::instance() -{ - return declarativeDebugMessageService(); -} - -void QDebugMessageService::sendDebugMessage(QtMsgType type, - const QMessageLogContext &ctxt, - const char *buf) -{ - Q_D(QDebugMessageService); - - //We do not want to alter the message handling mechanism - //We just eavesdrop and forward the messages to a port - //only if a client is connected to it. - QByteArray message; - QDataStream ws(&message, QIODevice::WriteOnly); - ws << QByteArray("MESSAGE") << type << QString::fromLocal8Bit(buf).toUtf8(); - ws << QString::fromLatin1(ctxt.file).toUtf8(); - ws << ctxt.line << QString::fromLatin1(ctxt.function).toUtf8(); - - sendMessage(message); - if (d->oldMsgHandler) - (*d->oldMsgHandler)(type, ctxt, buf); -} - -void QDebugMessageService::stateChanged(State state) -{ - Q_D(QDebugMessageService); - - if (state != Enabled && d->prevState == Enabled) { - QMessageHandler handler = qInstallMessageHandler(d->oldMsgHandler); - // has our handler been overwritten in between? - if (handler != DebugMessageHandler) - qInstallMessageHandler(handler); - - } else if (state == Enabled && d->prevState != Enabled) { - d->oldMsgHandler = qInstallMessageHandler(DebugMessageHandler); - - } - - d->prevState = state; -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdebugmessageservice_p.h b/src/declarative/debugger/qdebugmessageservice_p.h deleted file mode 100644 index b907341541..0000000000 --- a/src/declarative/debugger/qdebugmessageservice_p.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDEBUGMESSAGESERVICE_P_H -#define QDEBUGMESSAGESERVICE_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 "qdeclarativedebugservice_p.h" - -#include <QtCore/qlogging.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QDebugMessageServicePrivate; - -class QDebugMessageService : public QDeclarativeDebugService -{ - Q_OBJECT -public: - QDebugMessageService(QObject *parent = 0); - - static QDebugMessageService *instance(); - - void sendDebugMessage(QtMsgType type, const QMessageLogContext &ctxt, - const char *buf); - -protected: - void stateChanged(State); - -private: - Q_DISABLE_COPY(QDebugMessageService) - Q_DECLARE_PRIVATE(QDebugMessageService) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDEBUGMESSAGESERVICE_P_H diff --git a/src/declarative/debugger/qdeclarativedebug.h b/src/declarative/debugger/qdeclarativedebug.h deleted file mode 100644 index e23e4ff41a..0000000000 --- a/src/declarative/debugger/qdeclarativedebug.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 - - -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 deleted file mode 100644 index df250f3ef6..0000000000 --- a/src/declarative/debugger/qdeclarativedebugclient.cpp +++ /dev/null @@ -1,421 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qdeclarativedebugclient_p.h" - -#include "qpacketprotocol_p.h" - -#include <QtCore/qdebug.h> -#include <QtCore/qstringlist.h> -#include <QtNetwork/qnetworkproxy.h> - -#include <private/qobject_p.h> - -QT_BEGIN_NAMESPACE - -const int protocolVersion = 1; -const QString serverId = QLatin1String("QDeclarativeDebugServer"); -const QString clientId = QLatin1String("QDeclarativeDebugClient"); - -class QDeclarativeDebugClientPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeDebugClient) -public: - QDeclarativeDebugClientPrivate(); - - QString name; - QDeclarativeDebugConnection *connection; -}; - -class QDeclarativeDebugConnectionPrivate : public QObject -{ - Q_OBJECT -public: - QDeclarativeDebugConnectionPrivate(QDeclarativeDebugConnection *c); - QDeclarativeDebugConnection *q; - QPacketProtocol *protocol; - QIODevice *device; - - bool gotHello; - QHash <QString, float> 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), device(0), gotHello(false) -{ - protocol = new QPacketProtocol(q, this); - QObject::connect(c, SIGNAL(connected()), this, SLOT(connected())); - QObject::connect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead())); -} - -void QDeclarativeDebugConnectionPrivate::advertisePlugins() -{ - if (!q->isConnected()) - return; - - QPacket pack; - pack << serverId << 1 << plugins.keys(); - protocol->send(pack); - q->flush(); -} - -void QDeclarativeDebugConnectionPrivate::connected() -{ - QPacket pack; - pack << serverId << 0 << protocolVersion << plugins.keys(); - protocol->send(pack); - q->flush(); -} - -void QDeclarativeDebugConnectionPrivate::readyRead() -{ - if (!gotHello) { - QPacket pack = protocol->read(); - QString name; - - pack >> name; - - bool validHello = false; - if (name == clientId) { - int op = -1; - pack >> op; - if (op == 0) { - int version = -1; - pack >> version; - if (version == protocolVersion) { - QStringList pluginNames; - QList<float> pluginVersions; - pack >> pluginNames; - if (!pack.isEmpty()) - pack >> pluginVersions; - - const int pluginNamesSize = pluginNames.size(); - const int pluginVersionsSize = pluginVersions.size(); - for (int i = 0; i < pluginNamesSize; ++i) { - float pluginVersion = 1.0; - if (i < pluginVersionsSize) - pluginVersion = pluginVersions.at(i); - serverPlugins.insert(pluginNames.at(i), pluginVersion); - } - - validHello = true; - } - } - } - - if (!validHello) { - qWarning("QDeclarativeDebugConnection: Invalid hello message"); - QObject::disconnect(protocol, SIGNAL(readyRead()), this, SLOT(readyRead())); - return; - } - gotHello = true; - - QHash<QString, QDeclarativeDebugClient *>::Iterator iter = plugins.begin(); - for (; iter != plugins.end(); ++iter) { - QDeclarativeDebugClient::State newState = QDeclarativeDebugClient::Unavailable; - if (serverPlugins.contains(iter.key())) - newState = QDeclarativeDebugClient::Enabled; - iter.value()->stateChanged(newState); - } - } - - while (protocol->packetsAvailable()) { - QPacket pack = protocol->read(); - QString name; - pack >> name; - - if (name == clientId) { - int op = -1; - pack >> op; - - if (op == 1) { - // Service Discovery - QHash<QString, float> oldServerPlugins = serverPlugins; - serverPlugins.clear(); - - QStringList pluginNames; - QList<float> pluginVersions; - pack >> pluginNames; - if (!pack.isEmpty()) - pack >> pluginVersions; - - const int pluginNamesSize = pluginNames.size(); - const int pluginVersionsSize = pluginVersions.size(); - for (int i = 0; i < pluginNamesSize; ++i) { - float pluginVersion = 1.0; - if (i < pluginVersionsSize) - pluginVersion = pluginVersions.at(i); - serverPlugins.insert(pluginNames.at(i), pluginVersion); - } - - QHash<QString, QDeclarativeDebugClient *>::Iterator iter = plugins.begin(); - for (; iter != plugins.end(); ++iter) { - const QString pluginName = iter.key(); - QDeclarativeDebugClient::State newSate = QDeclarativeDebugClient::Unavailable; - if (serverPlugins.contains(pluginName)) - newSate = QDeclarativeDebugClient::Enabled; - - if (oldServerPlugins.contains(pluginName) - != serverPlugins.contains(pluginName)) { - iter.value()->stateChanged(newSate); - } - } - } else { - qWarning() << "QDeclarativeDebugConnection: Unknown control message id" << op; - } - } else { - QByteArray message; - pack >> message; - - QHash<QString, QDeclarativeDebugClient *>::Iterator iter = - plugins.find(name); - if (iter == plugins.end()) { - qWarning() << "QDeclarativeDebugConnection: Message received for missing plugin" << name; - } else { - (*iter)->messageReceived(message); - } - } - } -} - -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) - : QIODevice(parent), d(new QDeclarativeDebugConnectionPrivate(this)) -{ -} - -QDeclarativeDebugConnection::~QDeclarativeDebugConnection() -{ - QHash<QString, QDeclarativeDebugClient*>::iterator iter = d->plugins.begin(); - for (; iter != d->plugins.end(); ++iter) { - iter.value()->d_func()->connection = 0; - iter.value()->stateChanged(QDeclarativeDebugClient::NotConnected); - } -} - -bool QDeclarativeDebugConnection::isConnected() const -{ - 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()->stateChanged(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) -{ -} - -QDeclarativeDebugClient::QDeclarativeDebugClient(const QString &name, - QDeclarativeDebugConnection *parent) - : QObject(*(new QDeclarativeDebugClientPrivate), parent) -{ - Q_D(QDeclarativeDebugClient); - d->name = name; - d->connection = parent; - - if (!d->connection) - return; - - if (d->connection->d->plugins.contains(name)) { - qWarning() << "QDeclarativeDebugClient: Conflicting plugin name" << name; - d->connection = 0; - } else { - d->connection->d->plugins.insert(name, this); - d->connection->d->advertisePlugins(); - } -} - -QDeclarativeDebugClient::~QDeclarativeDebugClient() -{ - Q_D(QDeclarativeDebugClient); - if (d->connection && d->connection->d) { - d->connection->d->plugins.remove(d->name); - d->connection->d->advertisePlugins(); - } -} - -QString QDeclarativeDebugClient::name() const -{ - Q_D(const QDeclarativeDebugClient); - return d->name; -} - -float QDeclarativeDebugClient::serviceVersion() const -{ - Q_D(const QDeclarativeDebugClient); - if (d->connection->d->serverPlugins.contains(d->name)) - return d->connection->d->serverPlugins.value(d->name); - return -1; -} - -QDeclarativeDebugClient::State QDeclarativeDebugClient::state() const -{ - Q_D(const QDeclarativeDebugClient); - if (!d->connection - || !d->connection->isConnected() - || !d->connection->d->gotHello) - return NotConnected; - - if (d->connection->d->serverPlugins.contains(d->name)) - return Enabled; - - return Unavailable; -} - -void QDeclarativeDebugClient::sendMessage(const QByteArray &message) -{ - Q_D(QDeclarativeDebugClient); - if (state() != Enabled) - return; - - QPacket pack; - pack << d->name << message; - d->connection->d->protocol->send(pack); - d->connection->flush(); -} - -void QDeclarativeDebugClient::stateChanged(State) -{ -} - -void QDeclarativeDebugClient::messageReceived(const QByteArray &) -{ -} - -QT_END_NAMESPACE - -#include <qdeclarativedebugclient.moc> diff --git a/src/declarative/debugger/qdeclarativedebugclient_p.h b/src/declarative/debugger/qdeclarativedebugclient_p.h deleted file mode 100644 index 93c5be9e44..0000000000 --- a/src/declarative/debugger/qdeclarativedebugclient_p.h +++ /dev/null @@ -1,131 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 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> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeDebugConnectionPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugConnection : public QIODevice -{ - Q_OBJECT - Q_DISABLE_COPY(QDeclarativeDebugConnection) -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; - friend class QDeclarativeDebugClientPrivate; -}; - -class QDeclarativeDebugClientPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugClient : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeDebugClient) - Q_DISABLE_COPY(QDeclarativeDebugClient) - -public: - enum State { NotConnected, Unavailable, Enabled }; - - QDeclarativeDebugClient(const QString &, QDeclarativeDebugConnection *parent); - ~QDeclarativeDebugClient(); - - QString name() const; - float serviceVersion() const; - State state() const; - - virtual void sendMessage(const QByteArray &); - -protected: - virtual void stateChanged(State); - virtual void messageReceived(const QByteArray &); - -private: - friend class QDeclarativeDebugConnection; - friend class QDeclarativeDebugConnectionPrivate; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGCLIENT_H diff --git a/src/declarative/debugger/qdeclarativedebughelper.cpp b/src/declarative/debugger/qdeclarativedebughelper.cpp deleted file mode 100644 index 45d488fe1b..0000000000 --- a/src/declarative/debugger/qdeclarativedebughelper.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qdeclarativedebughelper_p.h" - -#include <QtCore/QAbstractAnimation> -#include <QtDeclarative/QJSEngine> - -#include <private/qdeclarativeengine_p.h> -#include <private/qabstractanimation_p.h> -#include <private/qdeclarativeengine_p.h> - -QT_BEGIN_NAMESPACE - -void QDeclarativeDebugHelper::setAnimationSlowDownFactor(qreal factor) -{ - QUnifiedTimer *timer = QUnifiedTimer::instance(); - timer->setSlowModeEnabled(factor != 1.0); - timer->setSlowdownFactor(factor); -} - -void QDeclarativeDebugHelper::enableDebugging() { - qWarning("QDeclarativeDebugHelper::enableDebugging() is deprecated! Add CONFIG += declarative_debug to your .pro file instead."); -#ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL - if (!QDeclarativeEnginePrivate::qml_debugging_enabled) { - qWarning("Qml debugging is enabled. Only use this in a safe environment!"); - } - QDeclarativeEnginePrivate::qml_debugging_enabled = true; -#endif -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativedebughelper_p.h b/src/declarative/debugger/qdeclarativedebughelper_p.h deleted file mode 100644 index d24bc8c19f..0000000000 --- a/src/declarative/debugger/qdeclarativedebughelper_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEDEBUGHELPER_P_H -#define QDECLARATIVEDEBUGHELPER_P_H - -#include <QtCore/qglobal.h> - -#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 - -class QDeclarativeEngine; - -#ifndef QT_BUILD_DECLARATIVE_LIB -#warning Use of this header file is deprecated! Add CONFIG += declarative_debug to your .pro file instead. -#endif - -// Helper methods to access private API through a stable interface -// This is used in the qmljsdebugger library of QtCreator. -class Q_DECLARATIVE_EXPORT QDeclarativeDebugHelper -{ -public: - static void setAnimationSlowDownFactor(qreal factor); - - // Enables remote debugging functionality - // Only use this for debugging in a safe environment! - static void enableDebugging(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGHELPER_P_H diff --git a/src/declarative/debugger/qdeclarativedebugserver.cpp b/src/declarative/debugger/qdeclarativedebugserver.cpp deleted file mode 100644 index 482847c7a7..0000000000 --- a/src/declarative/debugger/qdeclarativedebugserver.cpp +++ /dev/null @@ -1,539 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qdeclarativedebugserver_p.h" -#include "qdeclarativedebugservice_p.h" -#include "qdeclarativedebugservice_p_p.h" -#include <private/qdeclarativeengine_p.h> - -#include <QtCore/QDir> -#include <QtCore/QPluginLoader> -#include <QtCore/QStringList> -#include <QtCore/qwaitcondition.h> - -#include <private/qobject_p.h> -#include <private/qcoreapplication_p.h> - -QT_BEGIN_NAMESPACE - -/* - QDeclarativeDebug Protocol (Version 1): - - handshake: - 1. Client sends - "QDeclarativeDebugServer" 0 version pluginNames - version: an int representing the highest protocol version the client knows - pluginNames: plugins available on client side - 2. Server sends - "QDeclarativeDebugClient" 0 version pluginNames pluginVersions - version: an int representing the highest protocol version the client & server know - pluginNames: plugins available on server side. plugins both in the client and server message are enabled. - client plugin advertisement - 1. Client sends - "QDeclarativeDebugServer" 1 pluginNames - server plugin advertisement - 1. Server sends - "QDeclarativeDebugClient" 1 pluginNames pluginVersions - plugin communication: - Everything send with a header different to "QDeclarativeDebugServer" is sent to the appropriate plugin. - */ - -const int protocolVersion = 1; - -// print detailed information about loading of plugins -DEFINE_BOOL_CONFIG_OPTION(qmlDebugVerbose, QML_DEBUGGER_VERBOSE) - -class QDeclarativeDebugServerThread; - -class QDeclarativeDebugServerPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeDebugServer) -public: - QDeclarativeDebugServerPrivate(); - - void advertisePlugins(); - QDeclarativeDebugServerConnection *loadConnectionPlugin(const QString &pluginName); - - QDeclarativeDebugServerConnection *connection; - QHash<QString, QDeclarativeDebugService *> plugins; - mutable QReadWriteLock pluginsLock; - QStringList clientPlugins; - bool gotHello; - - QMutex messageArrivedMutex; - QWaitCondition messageArrivedCondition; - QStringList waitingForMessageNames; - QDeclarativeDebugServerThread *thread; - QPluginLoader loader; - -private: - // private slot - void _q_sendMessages(const QList<QByteArray> &messages); -}; - -class QDeclarativeDebugServerThread : public QThread -{ -public: - void setPluginName(const QString &pluginName) { - m_pluginName = pluginName; - } - - void setPort(int port, bool block) { - m_port = port; - m_block = block; - } - - void run(); - -private: - QString m_pluginName; - int m_port; - bool m_block; -}; - -QDeclarativeDebugServerPrivate::QDeclarativeDebugServerPrivate() : - connection(0), - gotHello(false), - thread(0) -{ - // used in _q_sendMessages - qRegisterMetaType<QList<QByteArray> >("QList<QByteArray>"); -} - -void QDeclarativeDebugServerPrivate::advertisePlugins() -{ - Q_Q(QDeclarativeDebugServer); - - if (!gotHello) - return; - - QByteArray message; - { - QDataStream out(&message, QIODevice::WriteOnly); - QStringList pluginNames; - QList<float> pluginVersions; - foreach (QDeclarativeDebugService *service, plugins.values()) { - pluginNames << service->name(); - pluginVersions << service->version(); - } - out << QString(QLatin1String("QDeclarativeDebugClient")) << 1 << pluginNames << pluginVersions; - } - - QMetaObject::invokeMethod(q, "_q_sendMessages", Qt::QueuedConnection, Q_ARG(QList<QByteArray>, QList<QByteArray>() << message)); -} - -QDeclarativeDebugServerConnection *QDeclarativeDebugServerPrivate::loadConnectionPlugin( - const QString &pluginName) -{ -#ifndef QT_NO_LIBRARY - QStringList pluginCandidates; - const QStringList paths = QCoreApplication::libraryPaths(); - foreach (const QString &libPath, paths) { - const QDir dir(libPath + QLatin1String("/qmltooling")); - if (dir.exists()) { - QStringList plugins(dir.entryList(QDir::Files)); - foreach (const QString &pluginPath, plugins) { - if (QFileInfo(pluginPath).fileName().contains(pluginName)) - pluginCandidates << dir.absoluteFilePath(pluginPath); - } - } - } - - foreach (const QString &pluginPath, pluginCandidates) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeDebugServer: Trying to load plugin " << pluginPath << "..."; - - loader.setFileName(pluginPath); - if (!loader.load()) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeDebugServer: Error while loading: " << loader.errorString(); - continue; - } - if (QObject *instance = loader.instance()) - connection = qobject_cast<QDeclarativeDebugServerConnection*>(instance); - - if (connection) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeDebugServer: Plugin successfully loaded."; - - return connection; - } - - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeDebugServer: Plugin does not implement interface QDeclarativeDebugServerConnection."; - - loader.unload(); - } -#endif - return 0; -} - -void QDeclarativeDebugServerThread::run() -{ - QDeclarativeDebugServer *server = QDeclarativeDebugServer::instance(); - QDeclarativeDebugServerConnection *connection - = server->d_func()->loadConnectionPlugin(m_pluginName); - if (connection) { - connection->setServer(QDeclarativeDebugServer::instance()); - connection->setPort(m_port, m_block); - } else { - QCoreApplicationPrivate *appD = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(qApp)); - qWarning() << QString::fromAscii("QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". " - "Remote debugger plugin has not been found.").arg(appD->qmljsDebugArgumentsString()); - } - - exec(); - - // make sure events still waiting are processed - QEventLoop eventLoop; - eventLoop.processEvents(QEventLoop::AllEvents); -} - -bool QDeclarativeDebugServer::hasDebuggingClient() const -{ - Q_D(const QDeclarativeDebugServer); - return d->connection - && d->connection->isConnected() - && d->gotHello; -} - -static QDeclarativeDebugServer *qDeclarativeDebugServer = 0; - - -static void cleanup() -{ - delete qDeclarativeDebugServer; - qDeclarativeDebugServer = 0; -} - -QDeclarativeDebugServer *QDeclarativeDebugServer::instance() -{ - static bool commandLineTested = false; - - if (!commandLineTested) { - commandLineTested = true; - - QCoreApplicationPrivate *appD = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(qApp)); -#ifndef QDECLARATIVE_NO_DEBUG_PROTOCOL - // ### remove port definition when protocol is changed - int port = 0; - bool block = false; - bool ok = false; - - // format: qmljsdebugger=port:3768[,block] OR qmljsdebugger=ost[,block] - if (!appD->qmljsDebugArgumentsString().isEmpty()) { - if (!QDeclarativeEnginePrivate::qml_debugging_enabled) { - qWarning() << QString::fromLatin1( - "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". " - "Debugging has not been enabled.").arg( - appD->qmljsDebugArgumentsString()); - return 0; - } - - QString pluginName; - if (appD->qmljsDebugArgumentsString().indexOf(QLatin1String("port:")) == 0) { - int separatorIndex = appD->qmljsDebugArgumentsString().indexOf(QLatin1Char(',')); - port = appD->qmljsDebugArgumentsString().mid(5, separatorIndex - 5).toInt(&ok); - pluginName = QLatin1String("qmldbg_tcp"); - } else if (appD->qmljsDebugArgumentsString().contains(QLatin1String("ost"))) { - pluginName = QLatin1String("qmldbg_ost"); - ok = true; - } - - block = appD->qmljsDebugArgumentsString().contains(QLatin1String("block")); - - if (ok) { - qDeclarativeDebugServer = new QDeclarativeDebugServer(); - QDeclarativeDebugServerThread *thread = new QDeclarativeDebugServerThread; - qDeclarativeDebugServer->d_func()->thread = thread; - qDeclarativeDebugServer->moveToThread(thread); - thread->setPluginName(pluginName); - thread->setPort(port, block); - thread->start(); - - if (block) { - QDeclarativeDebugServerPrivate *d = qDeclarativeDebugServer->d_func(); - d->messageArrivedMutex.lock(); - d->messageArrivedCondition.wait(&d->messageArrivedMutex); - d->messageArrivedMutex.unlock(); - } - - } else { - qWarning() << QString::fromLatin1( - "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". " - "Format is -qmljsdebugger=port:<port>[,block]").arg( - appD->qmljsDebugArgumentsString()); - } - } -#else - if (!appD->qmljsDebugArgumentsString().isEmpty()) { - qWarning() << QString::fromLatin1( - "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=%1\". " - "QtDeclarative is not configured for debugging.").arg( - appD->qmljsDebugArgumentsString()); - } -#endif - } - - return qDeclarativeDebugServer; -} - -QDeclarativeDebugServer::QDeclarativeDebugServer() - : QObject(*(new QDeclarativeDebugServerPrivate)) -{ - qAddPostRoutine(cleanup); -} - -QDeclarativeDebugServer::~QDeclarativeDebugServer() -{ - Q_D(QDeclarativeDebugServer); - - QReadLocker(&d->pluginsLock); - { - foreach (QDeclarativeDebugService *service, d->plugins.values()) { - service->stateAboutToBeChanged(QDeclarativeDebugService::NotConnected); - service->d_func()->server = 0; - service->d_func()->state = QDeclarativeDebugService::NotConnected; - service->stateChanged(QDeclarativeDebugService::NotConnected); - } - } - - if (d->thread) { - d->thread->exit(); - d->thread->wait(); - delete d->thread; - } - delete d->connection; -} - -void QDeclarativeDebugServer::receiveMessage(const QByteArray &message) -{ - Q_D(QDeclarativeDebugServer); - - QDataStream in(message); - - QString name; - - in >> name; - if (name == QLatin1String("QDeclarativeDebugServer")) { - int op = -1; - in >> op; - if (op == 0) { - int version; - in >> version >> d->clientPlugins; - - // Send the hello answer immediately, since it needs to arrive before - // the plugins below start sending messages. - QByteArray helloAnswer; - { - QDataStream out(&helloAnswer, QIODevice::WriteOnly); - QStringList pluginNames; - QList<float> pluginVersions; - foreach (QDeclarativeDebugService *service, d->plugins.values()) { - pluginNames << service->name(); - pluginVersions << service->version(); - } - - out << QString(QLatin1String("QDeclarativeDebugClient")) << 0 << protocolVersion << pluginNames << pluginVersions; - } - d->connection->send(QList<QByteArray>() << helloAnswer); - - d->gotHello = true; - - QReadLocker(&d->pluginsLock); - QHash<QString, QDeclarativeDebugService*>::ConstIterator iter = d->plugins.constBegin(); - for (; iter != d->plugins.constEnd(); ++iter) { - QDeclarativeDebugService::State newState = QDeclarativeDebugService::Unavailable; - if (d->clientPlugins.contains(iter.key())) - newState = QDeclarativeDebugService::Enabled; - iter.value()->d_func()->state = newState; - iter.value()->stateChanged(newState); - } - - qWarning("QDeclarativeDebugServer: Connection established"); - d->messageArrivedCondition.wakeAll(); - - } else if (op == 1) { - - // Service Discovery - QStringList oldClientPlugins = d->clientPlugins; - in >> d->clientPlugins; - - QReadLocker(&d->pluginsLock); - QHash<QString, QDeclarativeDebugService*>::ConstIterator iter = d->plugins.constBegin(); - for (; iter != d->plugins.constEnd(); ++iter) { - const QString pluginName = iter.key(); - QDeclarativeDebugService::State newState = QDeclarativeDebugService::Unavailable; - if (d->clientPlugins.contains(pluginName)) - newState = QDeclarativeDebugService::Enabled; - - if (oldClientPlugins.contains(pluginName) - != d->clientPlugins.contains(pluginName)) { - iter.value()->d_func()->state = newState; - iter.value()->stateChanged(newState); - } - } - - } else { - qWarning("QDeclarativeDebugServer: Invalid control message %d", op); - d->connection->disconnect(); - return; - } - - } else { - if (d->gotHello) { - QByteArray message; - in >> message; - - QReadLocker(&d->pluginsLock); - QHash<QString, QDeclarativeDebugService *>::Iterator iter = d->plugins.find(name); - if (iter == d->plugins.end()) { - qWarning() << "QDeclarativeDebugServer: Message received for missing plugin" << name; - } else { - (*iter)->messageReceived(message); - - if (d->waitingForMessageNames.removeOne(name)) - d->messageArrivedCondition.wakeAll(); - } - } else { - qWarning("QDeclarativeDebugServer: Invalid hello message"); - } - - } -} - -void QDeclarativeDebugServerPrivate::_q_sendMessages(const QList<QByteArray> &messages) -{ - if (connection) - connection->send(messages); -} - -QList<QDeclarativeDebugService*> QDeclarativeDebugServer::services() const -{ - const Q_D(QDeclarativeDebugServer); - QReadLocker(&d->pluginsLock); - return d->plugins.values(); -} - -QStringList QDeclarativeDebugServer::serviceNames() const -{ - const Q_D(QDeclarativeDebugServer); - QReadLocker(&d->pluginsLock); - return d->plugins.keys(); -} - -bool QDeclarativeDebugServer::addService(QDeclarativeDebugService *service) -{ - Q_D(QDeclarativeDebugServer); - { - QWriteLocker(&d->pluginsLock); - if (!service || d->plugins.contains(service->name())) - return false; - d->plugins.insert(service->name(), service); - } - { - QReadLocker(&d->pluginsLock); - d->advertisePlugins(); - QDeclarativeDebugService::State newState = QDeclarativeDebugService::Unavailable; - if (d->clientPlugins.contains(service->name())) - newState = QDeclarativeDebugService::Enabled; - service->d_func()->state = newState; - } - return true; -} - -bool QDeclarativeDebugServer::removeService(QDeclarativeDebugService *service) -{ - Q_D(QDeclarativeDebugServer); - { - QWriteLocker(&d->pluginsLock); - if (!service || !d->plugins.contains(service->name())) - return false; - d->plugins.remove(service->name()); - } - { - QReadLocker(&d->pluginsLock); - QDeclarativeDebugService::State newState = QDeclarativeDebugService::NotConnected; - service->stateAboutToBeChanged(newState); - d->advertisePlugins(); - service->d_func()->server = 0; - service->d_func()->state = newState; - service->stateChanged(newState); - } - - return true; -} - -void QDeclarativeDebugServer::sendMessages(QDeclarativeDebugService *service, - const QList<QByteArray> &messages) -{ - QList<QByteArray> prefixedMessages; - foreach (const QByteArray &message, messages) { - QByteArray prefixed; - QDataStream out(&prefixed, QIODevice::WriteOnly); - out << service->name() << message; - prefixedMessages << prefixed; - } - - QMetaObject::invokeMethod(this, "_q_sendMessages", Qt::QueuedConnection, Q_ARG(QList<QByteArray>, prefixedMessages)); -} - -bool QDeclarativeDebugServer::waitForMessage(QDeclarativeDebugService *service) -{ - Q_D(QDeclarativeDebugServer); - QReadLocker(&d->pluginsLock); - - if (!service - || !d->plugins.contains(service->name())) - return false; - - d->messageArrivedMutex.lock(); - d->waitingForMessageNames << service->name(); - do { - d->messageArrivedCondition.wait(&d->messageArrivedMutex); - } while (d->waitingForMessageNames.contains(service->name())); - d->messageArrivedMutex.unlock(); - return true; -} - -QT_END_NAMESPACE - -#include "moc_qdeclarativedebugserver_p.cpp" diff --git a/src/declarative/debugger/qdeclarativedebugserver_p.h b/src/declarative/debugger/qdeclarativedebugserver_p.h deleted file mode 100644 index 8f7f748761..0000000000 --- a/src/declarative/debugger/qdeclarativedebugserver_p.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEDEBUGSERVER_H -#define QDECLARATIVEDEBUGSERVER_H - -#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 - - -class QDeclarativeDebugService; - -class QDeclarativeDebugServerPrivate; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugServer : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeDebugServer) - Q_DISABLE_COPY(QDeclarativeDebugServer) -public: - ~QDeclarativeDebugServer(); - - static QDeclarativeDebugServer *instance(); - - void setConnection(QDeclarativeDebugServerConnection *connection); - - bool hasDebuggingClient() const; - - QList<QDeclarativeDebugService*> services() const; - QStringList serviceNames() const; - - - bool addService(QDeclarativeDebugService *service); - bool removeService(QDeclarativeDebugService *service); - - void receiveMessage(const QByteArray &message); - - bool waitForMessage(QDeclarativeDebugService *service); - void sendMessages(QDeclarativeDebugService *service, const QList<QByteArray> &messages); - -private: - friend class QDeclarativeDebugService; - friend class QDeclarativeDebugServicePrivate; - friend class QDeclarativeDebugServerThread; - QDeclarativeDebugServer(); - Q_PRIVATE_SLOT(d_func(), void _q_sendMessages(QList<QByteArray>)) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGSERVICE_H diff --git a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h b/src/declarative/debugger/qdeclarativedebugserverconnection_p.h deleted file mode 100644 index aa1c8aa0f1..0000000000 --- a/src/declarative/debugger/qdeclarativedebugserverconnection_p.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEDEBUGSERVERCONNECTION_H -#define QDECLARATIVEDEBUGSERVERCONNECTION_H - -#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 - - -class QDeclarativeDebugServer; -class Q_DECLARATIVE_EXPORT QDeclarativeDebugServerConnection -{ -public: - QDeclarativeDebugServerConnection() {} - virtual ~QDeclarativeDebugServerConnection() {} - - virtual void setServer(QDeclarativeDebugServer *server) = 0; - virtual void setPort(int port, bool bock) = 0; - virtual bool isConnected() const = 0; - virtual void send(const QList<QByteArray> &messages) = 0; - virtual void disconnect() = 0; - virtual bool waitForMessage() = 0; -}; - -Q_DECLARE_INTERFACE(QDeclarativeDebugServerConnection, "com.trolltech.Qt.QDeclarativeDebugServerConnection/1.0") - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGSERVERCONNECTION_H diff --git a/src/declarative/debugger/qdeclarativedebugservice.cpp b/src/declarative/debugger/qdeclarativedebugservice.cpp deleted file mode 100644 index 96344d7717..0000000000 --- a/src/declarative/debugger/qdeclarativedebugservice.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qdeclarativedebugservice_p.h" -#include "qdeclarativedebugservice_p_p.h" -#include "qdeclarativedebugserver_p.h" - -#include <QtCore/QDebug> -#include <QtCore/QStringList> - -QT_BEGIN_NAMESPACE - -QDeclarativeDebugServicePrivate::QDeclarativeDebugServicePrivate() - : server(0) -{ -} - -QDeclarativeDebugService::QDeclarativeDebugService(const QString &name, float version, QObject *parent) - : QObject(*(new QDeclarativeDebugServicePrivate), parent) -{ - Q_D(QDeclarativeDebugService); - d->name = name; - d->version = version; - d->server = QDeclarativeDebugServer::instance(); - d->state = QDeclarativeDebugService::NotConnected; - - -} - -QDeclarativeDebugService::QDeclarativeDebugService(QDeclarativeDebugServicePrivate &dd, - const QString &name, float version, QObject *parent) - : QObject(dd, parent) -{ - Q_D(QDeclarativeDebugService); - d->name = name; - d->version = version; - d->server = QDeclarativeDebugServer::instance(); - d->state = QDeclarativeDebugService::NotConnected; -} - -/** - Registers the service. This should be called in the constructor of the inherited class. From - then on the service might get asynchronous calls to messageReceived(). - */ -QDeclarativeDebugService::State QDeclarativeDebugService::registerService() -{ - Q_D(QDeclarativeDebugService); - if (!d->server) - return NotConnected; - - if (d->server->serviceNames().contains(d->name)) { - qWarning() << "QDeclarativeDebugService: Conflicting plugin name" << d->name; - d->server = 0; - } else { - d->server->addService(this); - } - return state(); -} - -QDeclarativeDebugService::~QDeclarativeDebugService() -{ - Q_D(const QDeclarativeDebugService); - if (d->server) { - d->server->removeService(this); - } -} - -QString QDeclarativeDebugService::name() const -{ - Q_D(const QDeclarativeDebugService); - return d->name; -} - -float QDeclarativeDebugService::version() const -{ - Q_D(const QDeclarativeDebugService); - return d->version; -} - -QDeclarativeDebugService::State QDeclarativeDebugService::state() const -{ - Q_D(const QDeclarativeDebugService); - return d->state; -} - -namespace { - -struct ObjectReference -{ - QPointer<QObject> object; - int id; -}; - -struct ObjectReferenceHash -{ - ObjectReferenceHash() : nextId(0) {} - - QHash<QObject *, ObjectReference> objects; - QHash<int, QObject *> ids; - - int nextId; -}; - -} -Q_GLOBAL_STATIC(ObjectReferenceHash, objectReferenceHash); - - -/*! - Returns a unique id for \a object. Calling this method multiple times - for the same object will return the same id. -*/ -int QDeclarativeDebugService::idForObject(QObject *object) -{ - if (!object) - return -1; - - ObjectReferenceHash *hash = objectReferenceHash(); - QHash<QObject *, ObjectReference>::Iterator iter = - hash->objects.find(object); - - if (iter == hash->objects.end()) { - int id = hash->nextId++; - - hash->ids.insert(id, object); - iter = hash->objects.insert(object, ObjectReference()); - iter->object = object; - iter->id = id; - } else if (iter->object != object) { - int id = hash->nextId++; - - hash->ids.remove(iter->id); - - hash->ids.insert(id, object); - iter->object = object; - iter->id = id; - } - return iter->id; -} - -/*! - Returns the object for unique \a id. If the object has not previously been - assigned an id, through idForObject(), then 0 is returned. If the object - has been destroyed, 0 is returned. -*/ -QObject *QDeclarativeDebugService::objectForId(int id) -{ - ObjectReferenceHash *hash = objectReferenceHash(); - - QHash<int, QObject *>::Iterator iter = hash->ids.find(id); - if (iter == hash->ids.end()) - return 0; - - - QHash<QObject *, ObjectReference>::Iterator objIter = - hash->objects.find(*iter); - Q_ASSERT(objIter != hash->objects.end()); - - if (objIter->object == 0) { - hash->ids.erase(iter); - hash->objects.erase(objIter); - return 0; - } else { - return *iter; - } -} - -bool QDeclarativeDebugService::isDebuggingEnabled() -{ - return QDeclarativeDebugServer::instance() != 0; -} - -bool QDeclarativeDebugService::hasDebuggingClient() -{ - return QDeclarativeDebugServer::instance() != 0 - && QDeclarativeDebugServer::instance()->hasDebuggingClient(); -} - -QString QDeclarativeDebugService::objectToString(QObject *obj) -{ - if(!obj) - return QLatin1String("NULL"); - - QString objectName = obj->objectName(); - if(objectName.isEmpty()) - objectName = QLatin1String("<unnamed>"); - - QString rv = QString::fromUtf8(obj->metaObject()->className()) + - QLatin1String(": ") + objectName; - - return rv; -} - -void QDeclarativeDebugService::sendMessage(const QByteArray &message) -{ - sendMessages(QList<QByteArray>() << message); -} - -void QDeclarativeDebugService::sendMessages(const QList<QByteArray> &messages) -{ - Q_D(QDeclarativeDebugService); - - if (state() != Enabled) - return; - - d->server->sendMessages(this, messages); -} - -bool QDeclarativeDebugService::waitForMessage() -{ - Q_D(QDeclarativeDebugService); - - if (state() != Enabled) - return false; - - return d->server->waitForMessage(this); -} - -void QDeclarativeDebugService::stateAboutToBeChanged(State) -{ -} - -void QDeclarativeDebugService::stateChanged(State) -{ -} - -void QDeclarativeDebugService::messageReceived(const QByteArray &) -{ -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativedebugservice_p.h b/src/declarative/debugger/qdeclarativedebugservice_p.h deleted file mode 100644 index 203e27ad09..0000000000 --- a/src/declarative/debugger/qdeclarativedebugservice_p.h +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEDEBUGSERVICE_H -#define QDECLARATIVEDEBUGSERVICE_H - -#include <QtCore/qobject.h> - -#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 - - -class QDeclarativeDebugServicePrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugService : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QDeclarativeDebugService) - Q_DISABLE_COPY(QDeclarativeDebugService) - -public: - explicit QDeclarativeDebugService(const QString &, float version, QObject *parent = 0); - ~QDeclarativeDebugService(); - - QString name() const; - float version() const; - - enum State { NotConnected, Unavailable, Enabled }; - State state() const; - - void sendMessage(const QByteArray &); - void sendMessages(const QList<QByteArray> &); - bool waitForMessage(); - - static int idForObject(QObject *); - static QObject *objectForId(int); - - static QString objectToString(QObject *obj); - - static bool isDebuggingEnabled(); - static bool hasDebuggingClient(); - -protected: - QDeclarativeDebugService(QDeclarativeDebugServicePrivate &dd, const QString &name, float version, QObject *parent = 0); - - State registerService(); - - virtual void stateAboutToBeChanged(State); - virtual void stateChanged(State); - virtual void messageReceived(const QByteArray &); - -private: - friend class QDeclarativeDebugServer; - friend class QDeclarativeDebugServerPrivate; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGSERVICE_H - diff --git a/src/declarative/debugger/qdeclarativedebugservice_p_p.h b/src/declarative/debugger/qdeclarativedebugservice_p_p.h deleted file mode 100644 index 6638ccbec7..0000000000 --- a/src/declarative/debugger/qdeclarativedebugservice_p_p.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 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> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeDebugServer; - -class QDeclarativeDebugServicePrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeDebugService) -public: - QDeclarativeDebugServicePrivate(); - - QString name; - float version; - QDeclarativeDebugServer *server; - QDeclarativeDebugService::State state; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGSERVICE_P_H diff --git a/src/declarative/debugger/qdeclarativedebugstatesdelegate_p.h b/src/declarative/debugger/qdeclarativedebugstatesdelegate_p.h deleted file mode 100644 index 868357723d..0000000000 --- a/src/declarative/debugger/qdeclarativedebugstatesdelegate_p.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEDEBUGSTATESDELEGATE_P_H -#define QDECLARATIVEDEBUGSTATESDELEGATE_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/qdeclarativeglobal_p.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeContext; -class QDeclarativeProperty; -class QObject; -class QString; -class QVariant; - -class QDeclarativeDebugStatesDelegate -{ -protected: - QDeclarativeDebugStatesDelegate() {} - -public: - virtual ~QDeclarativeDebugStatesDelegate() {} - - virtual void buildStatesList(QDeclarativeContext *ctxt, bool cleanList) = 0; - virtual void updateBinding(QDeclarativeContext *context, - const QDeclarativeProperty &property, - const QVariant &expression, bool isLiteralValue, - const QString &fileName, int line, int column, - bool *inBaseState) = 0; - virtual bool setBindingForInvalidProperty(QObject *object, - const QString &propertyName, - const QVariant &expression, - bool isLiteralValue) = 0; - virtual void resetBindingForInvalidProperty(QObject *object, - const QString &propertyName) = 0; - -private: - Q_DISABLE_COPY(QDeclarativeDebugStatesDelegate) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEDEBUGSTATESDELEGATE_P_H diff --git a/src/declarative/debugger/qdeclarativeenginedebug.cpp b/src/declarative/debugger/qdeclarativeenginedebug.cpp deleted file mode 100644 index 462f99937e..0000000000 --- a/src/declarative/debugger/qdeclarativeenginedebug.cpp +++ /dev/null @@ -1,1072 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qdeclarativeenginedebug_p.h" - -#include "qdeclarativedebugclient_p.h" - -#include "qdeclarativeenginedebugservice_p.h" - -#include <private/qobject_p.h> - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngineDebugClient : public QDeclarativeDebugClient -{ -public: - QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client, QDeclarativeEngineDebugPrivate *p); - -protected: - virtual void stateChanged(State state); - virtual void messageReceived(const QByteArray &); - -private: - QDeclarativeEngineDebugPrivate *priv; - friend class QDeclarativeEngineDebugPrivate; -}; - -class QDeclarativeEngineDebugPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QDeclarativeEngineDebug) -public: - QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *); - ~QDeclarativeEngineDebugPrivate(); - - void stateChanged(QDeclarativeEngineDebug::State status); - void message(const QByteArray &); - - QDeclarativeEngineDebugClient *client; - int nextId; - int getId(); - - void decode(QDataStream &, QDeclarativeDebugContextReference &); - void decode(QDataStream &, QDeclarativeDebugObjectReference &, bool simple); - - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugEnginesQuery *); - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugRootContextQuery *); - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugObjectQuery *); - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugExpressionQuery *); - static void remove(QDeclarativeEngineDebug *, QDeclarativeDebugWatch *); - - QHash<int, QDeclarativeDebugEnginesQuery *> enginesQuery; - QHash<int, QDeclarativeDebugRootContextQuery *> rootContextQuery; - QHash<int, QDeclarativeDebugObjectQuery *> objectQuery; - QHash<int, QDeclarativeDebugExpressionQuery *> expressionQuery; - - QHash<int, QDeclarativeDebugWatch *> watched; -}; - -QDeclarativeEngineDebugClient::QDeclarativeEngineDebugClient(QDeclarativeDebugConnection *client, - QDeclarativeEngineDebugPrivate *p) - : QDeclarativeDebugClient(QLatin1String("QDeclarativeEngine"), client), priv(p) -{ -} - -void QDeclarativeEngineDebugClient::stateChanged(State status) -{ - if (priv) - priv->stateChanged(static_cast<QDeclarativeEngineDebug::State>(status)); -} - -void QDeclarativeEngineDebugClient::messageReceived(const QByteArray &data) -{ - if (priv) - priv->message(data); -} - -QDeclarativeEngineDebugPrivate::QDeclarativeEngineDebugPrivate(QDeclarativeDebugConnection *c) - : client(new QDeclarativeEngineDebugClient(c, this)), nextId(0) -{ -} - -QDeclarativeEngineDebugPrivate::~QDeclarativeEngineDebugPrivate() -{ - if (client) - client->priv = 0; - delete client; - - QHash<int, QDeclarativeDebugEnginesQuery*>::iterator enginesIter = enginesQuery.begin(); - for (; enginesIter != enginesQuery.end(); ++enginesIter) { - enginesIter.value()->m_client = 0; - if (enginesIter.value()->state() == QDeclarativeDebugQuery::Waiting) - enginesIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash<int, QDeclarativeDebugRootContextQuery*>::iterator rootContextIter = rootContextQuery.begin(); - for (; rootContextIter != rootContextQuery.end(); ++rootContextIter) { - rootContextIter.value()->m_client = 0; - if (rootContextIter.value()->state() == QDeclarativeDebugQuery::Waiting) - rootContextIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash<int, QDeclarativeDebugObjectQuery*>::iterator objectIter = objectQuery.begin(); - for (; objectIter != objectQuery.end(); ++objectIter) { - objectIter.value()->m_client = 0; - if (objectIter.value()->state() == QDeclarativeDebugQuery::Waiting) - objectIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash<int, QDeclarativeDebugExpressionQuery*>::iterator exprIter = expressionQuery.begin(); - for (; exprIter != expressionQuery.end(); ++exprIter) { - exprIter.value()->m_client = 0; - if (exprIter.value()->state() == QDeclarativeDebugQuery::Waiting) - exprIter.value()->setState(QDeclarativeDebugQuery::Error); - } - - QHash<int, QDeclarativeDebugWatch*>::iterator watchIter = watched.begin(); - for (; watchIter != watched.end(); ++watchIter) { - watchIter.value()->m_client = 0; - watchIter.value()->setState(QDeclarativeDebugWatch::Dead); - } -} - -int QDeclarativeEngineDebugPrivate::getId() -{ - return nextId++; -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugEnginesQuery *q) -{ - if (c && q) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->enginesQuery.remove(q->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, - QDeclarativeDebugRootContextQuery *q) -{ - if (c && q) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->rootContextQuery.remove(q->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugObjectQuery *q) -{ - if (c && q) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->objectQuery.remove(q->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugExpressionQuery *q) -{ - if (c && q) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->expressionQuery.remove(q->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::remove(QDeclarativeEngineDebug *c, QDeclarativeDebugWatch *w) -{ - if (c && w) { - QDeclarativeEngineDebugPrivate *p = (QDeclarativeEngineDebugPrivate *)QObjectPrivate::get(c); - p->watched.remove(w->m_queryId); - } -} - -void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugObjectReference &o, - bool simple) -{ - QDeclarativeEngineDebugService::QDeclarativeObjectData data; - ds >> data; - o.m_debugId = data.objectId; - o.m_class = data.objectType; - o.m_idString = data.idString; - o.m_name = data.objectName; - 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; - - int childCount; - bool recur; - ds >> childCount >> recur; - - for (int ii = 0; ii < childCount; ++ii) { - o.m_children.append(QDeclarativeDebugObjectReference()); - decode(ds, o.m_children.last(), !recur); - } - - int propCount; - ds >> propCount; - - for (int ii = 0; ii < propCount; ++ii) { - QDeclarativeEngineDebugService::QDeclarativeObjectProperty data; - ds >> data; - QDeclarativeDebugPropertyReference prop; - prop.m_objectDebugId = o.m_debugId; - prop.m_name = data.name; - prop.m_binding = data.binding; - prop.m_hasNotifySignal = data.hasNotifySignal; - prop.m_valueTypeName = data.valueTypeName; - switch (data.type) { - 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; - } -} - -void QDeclarativeEngineDebugPrivate::decode(QDataStream &ds, QDeclarativeDebugContextReference &c) -{ - ds >> c.m_name >> c.m_debugId; - - int contextCount; - ds >> contextCount; - - for (int ii = 0; ii < contextCount; ++ii) { - c.m_contexts.append(QDeclarativeDebugContextReference()); - decode(ds, c.m_contexts.last()); - } - - int objectCount; - ds >> objectCount; - - for (int ii = 0; ii < objectCount; ++ii) { - QDeclarativeDebugObjectReference obj; - decode(ds, obj, true); - - obj.m_contextDebugId = c.m_debugId; - c.m_objects << obj; - } -} - -void QDeclarativeEngineDebugPrivate::stateChanged(QDeclarativeEngineDebug::State status) -{ - emit q_func()->stateChanged(status); -} - -void QDeclarativeEngineDebugPrivate::message(const QByteArray &data) -{ - QDataStream ds(data); - - QByteArray type; - ds >> type; - - //qDebug() << "QDeclarativeEngineDebugPrivate::message()" << type; - - if (type == "LIST_ENGINES_R") { - int queryId; - ds >> queryId; - - QDeclarativeDebugEnginesQuery *query = enginesQuery.value(queryId); - if (!query) - return; - enginesQuery.remove(queryId); - - int count; - ds >> count; - - for (int ii = 0; ii < count; ++ii) { - QDeclarativeDebugEngineReference ref; - ds >> ref.m_name; - ds >> ref.m_debugId; - query->m_engines << ref; - } - - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "LIST_OBJECTS_R") { - int queryId; - ds >> queryId; - - QDeclarativeDebugRootContextQuery *query = rootContextQuery.value(queryId); - if (!query) - return; - rootContextQuery.remove(queryId); - - if (!ds.atEnd()) - decode(ds, query->m_context); - - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "FETCH_OBJECT_R") { - int queryId; - ds >> queryId; - - QDeclarativeDebugObjectQuery *query = objectQuery.value(queryId); - if (!query) - return; - objectQuery.remove(queryId); - - if (!ds.atEnd()) - decode(ds, query->m_object, false); - - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "EVAL_EXPRESSION_R") { - int queryId; - QVariant result; - ds >> queryId >> result; - - QDeclarativeDebugExpressionQuery *query = expressionQuery.value(queryId); - if (!query) - return; - expressionQuery.remove(queryId); - - query->m_result = result; - query->m_client = 0; - query->setState(QDeclarativeDebugQuery::Completed); - } else if (type == "WATCH_PROPERTY_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QDeclarativeDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); - } else if (type == "WATCH_OBJECT_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QDeclarativeDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); - } else if (type == "WATCH_EXPR_OBJECT_R") { - int queryId; - bool ok; - ds >> queryId >> ok; - - QDeclarativeDebugWatch *watch = watched.value(queryId); - if (!watch) - return; - - watch->setState(ok ? QDeclarativeDebugWatch::Active : QDeclarativeDebugWatch::Inactive); - } else if (type == "UPDATE_WATCH") { - int queryId; - int debugId; - QByteArray name; - QVariant value; - ds >> queryId >> debugId >> name >> value; - - QDeclarativeDebugWatch *watch = watched.value(queryId, 0); - if (!watch) - return; - emit watch->valueChanged(name, value); - } else if (type == "OBJECT_CREATED") { - emit q_func()->newObjects(); - } -} - -QDeclarativeEngineDebug::QDeclarativeEngineDebug(QDeclarativeDebugConnection *client, QObject *parent) - : QObject(*(new QDeclarativeEngineDebugPrivate(client)), parent) -{ -} - -QDeclarativeEngineDebug::~QDeclarativeEngineDebug() -{ -} - -QDeclarativeEngineDebug::State QDeclarativeEngineDebug::state() const -{ - Q_D(const QDeclarativeEngineDebug); - - return static_cast<QDeclarativeEngineDebug::State>(d->client->state()); -} - -QDeclarativeDebugPropertyWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugPropertyReference &property, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugPropertyWatch *watch = new QDeclarativeDebugPropertyWatch(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = property.objectDebugId(); - watch->m_name = property.name(); - d->watched.insert(queryId, watch); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("WATCH_PROPERTY") << queryId << property.objectDebugId() << property.name().toUtf8(); - d->client->sendMessage(message); - } else { - watch->m_state = QDeclarativeDebugWatch::Dead; - } - - return watch; -} - -QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugContextReference &, const QString &, QObject *) -{ - qWarning("QDeclarativeEngineDebug::addWatch(): Not implemented"); - return 0; -} - -QDeclarativeDebugObjectExpressionWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugObjectReference &object, const QString &expr, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - QDeclarativeDebugObjectExpressionWatch *watch = new QDeclarativeDebugObjectExpressionWatch(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - watch->m_objectDebugId = object.debugId(); - watch->m_expr = expr; - 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 = QDeclarativeDebugWatch::Dead; - } - return watch; -} - -QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugObjectReference &object, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugWatch *watch = new QDeclarativeDebugWatch(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled) { - int queryId = d->getId(); - watch->m_queryId = queryId; - watch->m_client = this; - 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 = QDeclarativeDebugWatch::Dead; - } - - return watch; -} - -QDeclarativeDebugWatch *QDeclarativeEngineDebug::addWatch(const QDeclarativeDebugFileReference &, QObject *) -{ - qWarning("QDeclarativeEngineDebug::addWatch(): Not implemented"); - return 0; -} - -void QDeclarativeEngineDebug::removeWatch(QDeclarativeDebugWatch *watch) -{ - Q_D(QDeclarativeEngineDebug); - - if (!watch || !watch->m_client) - return; - - watch->m_client = 0; - watch->setState(QDeclarativeDebugWatch::Inactive); - - d->watched.remove(watch->queryId()); - - if (d->client && d->client->state() == QDeclarativeDebugClient::Enabled) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("NO_WATCH") << watch->queryId(); - d->client->sendMessage(message); - } -} - -QDeclarativeDebugEnginesQuery *QDeclarativeEngineDebug::queryAvailableEngines(QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugEnginesQuery *query = new QDeclarativeDebugEnginesQuery(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->enginesQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("LIST_ENGINES") << queryId; - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -QDeclarativeDebugRootContextQuery *QDeclarativeEngineDebug::queryRootContexts(const QDeclarativeDebugEngineReference &engine, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugRootContextQuery *query = new QDeclarativeDebugRootContextQuery(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled && engine.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->rootContextQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("LIST_OBJECTS") << queryId << engine.debugId(); - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObject(const QDeclarativeDebugObjectReference &object, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled && object.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->objectQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId() - << false << true; - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -QDeclarativeDebugObjectQuery *QDeclarativeEngineDebug::queryObjectRecursive(const QDeclarativeDebugObjectReference &object, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugObjectQuery *query = new QDeclarativeDebugObjectQuery(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled && object.debugId() != -1) { - query->m_client = this; - int queryId = d->getId(); - query->m_queryId = queryId; - d->objectQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("FETCH_OBJECT") << queryId << object.debugId() - << true << true; - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -QDeclarativeDebugExpressionQuery *QDeclarativeEngineDebug::queryExpressionResult(int objectDebugId, const QString &expr, QObject *parent) -{ - Q_D(QDeclarativeEngineDebug); - - QDeclarativeDebugExpressionQuery *query = new QDeclarativeDebugExpressionQuery(parent); - if (d->client->state() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - query->m_client = this; - query->m_expr = expr; - int queryId = d->getId(); - query->m_queryId = queryId; - d->expressionQuery.insert(queryId, query); - - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("EVAL_EXPRESSION") << queryId << objectDebugId << expr; - d->client->sendMessage(message); - } else { - query->m_state = QDeclarativeDebugQuery::Error; - } - - return query; -} - -bool QDeclarativeEngineDebug::setBindingForObject(int objectDebugId, const QString &propertyName, - const QVariant &bindingExpression, - bool isLiteralValue, - QString source, int line) -{ - Q_D(QDeclarativeEngineDebug); - - if (d->client->state() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("SET_BINDING") << objectDebugId << propertyName << bindingExpression << isLiteralValue << source << line; - d->client->sendMessage(message); - return true; - } else { - return false; - } -} - -bool QDeclarativeEngineDebug::resetBindingForObject(int objectDebugId, const QString &propertyName) -{ - Q_D(QDeclarativeEngineDebug); - - if (d->client->state() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("RESET_BINDING") << objectDebugId << propertyName; - d->client->sendMessage(message); - return true; - } else { - return false; - } -} - -bool QDeclarativeEngineDebug::setMethodBody(int objectDebugId, const QString &methodName, - const QString &methodBody) -{ - Q_D(QDeclarativeEngineDebug); - - if (d->client->state() == QDeclarativeDebugClient::Enabled && objectDebugId != -1) { - QByteArray message; - QDataStream ds(&message, QIODevice::WriteOnly); - ds << QByteArray("SET_METHOD_BODY") << objectDebugId << methodName << methodBody; - d->client->sendMessage(message); - return true; - } else { - return false; - } -} - -QDeclarativeDebugWatch::QDeclarativeDebugWatch(QObject *parent) - : QObject(parent), m_state(Waiting), m_queryId(-1), m_client(0), m_objectDebugId(-1) -{ -} - -QDeclarativeDebugWatch::~QDeclarativeDebugWatch() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -int QDeclarativeDebugWatch::queryId() const -{ - return m_queryId; -} - -int QDeclarativeDebugWatch::objectDebugId() const -{ - return m_objectDebugId; -} - -QDeclarativeDebugWatch::State QDeclarativeDebugWatch::state() const -{ - return m_state; -} - -void QDeclarativeDebugWatch::setState(State s) -{ - if (m_state == s) - return; - m_state = s; - emit stateChanged(m_state); -} - -QDeclarativeDebugPropertyWatch::QDeclarativeDebugPropertyWatch(QObject *parent) - : QDeclarativeDebugWatch(parent) -{ -} - -QString QDeclarativeDebugPropertyWatch::name() const -{ - return m_name; -} - - -QDeclarativeDebugObjectExpressionWatch::QDeclarativeDebugObjectExpressionWatch(QObject *parent) - : QDeclarativeDebugWatch(parent) -{ -} - -QString QDeclarativeDebugObjectExpressionWatch::expression() const -{ - return m_expr; -} - - -QDeclarativeDebugQuery::QDeclarativeDebugQuery(QObject *parent) - : QObject(parent), m_state(Waiting) -{ -} - -QDeclarativeDebugQuery::State QDeclarativeDebugQuery::state() const -{ - return m_state; -} - -bool QDeclarativeDebugQuery::isWaiting() const -{ - return m_state == Waiting; -} - -void QDeclarativeDebugQuery::setState(State s) -{ - if (m_state == s) - return; - m_state = s; - emit stateChanged(m_state); -} - -QDeclarativeDebugEnginesQuery::QDeclarativeDebugEnginesQuery(QObject *parent) - : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugEnginesQuery::~QDeclarativeDebugEnginesQuery() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -QList<QDeclarativeDebugEngineReference> QDeclarativeDebugEnginesQuery::engines() const -{ - return m_engines; -} - -QDeclarativeDebugRootContextQuery::QDeclarativeDebugRootContextQuery(QObject *parent) - : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugRootContextQuery::~QDeclarativeDebugRootContextQuery() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -QDeclarativeDebugContextReference QDeclarativeDebugRootContextQuery::rootContext() const -{ - return m_context; -} - -QDeclarativeDebugObjectQuery::QDeclarativeDebugObjectQuery(QObject *parent) - : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugObjectQuery::~QDeclarativeDebugObjectQuery() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -QDeclarativeDebugObjectReference QDeclarativeDebugObjectQuery::object() const -{ - return m_object; -} - -QDeclarativeDebugExpressionQuery::QDeclarativeDebugExpressionQuery(QObject *parent) - : QDeclarativeDebugQuery(parent), m_client(0), m_queryId(-1) -{ -} - -QDeclarativeDebugExpressionQuery::~QDeclarativeDebugExpressionQuery() -{ - if (m_client && m_queryId != -1) - QDeclarativeEngineDebugPrivate::remove(m_client, this); -} - -QVariant QDeclarativeDebugExpressionQuery::expression() const -{ - return m_expr; -} - -QVariant QDeclarativeDebugExpressionQuery::result() const -{ - return m_result; -} - -QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference() - : m_debugId(-1) -{ -} - -QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(int debugId) - : m_debugId(debugId) -{ -} - -QDeclarativeDebugEngineReference::QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &o) - : m_debugId(o.m_debugId), m_name(o.m_name) -{ -} - -QDeclarativeDebugEngineReference & -QDeclarativeDebugEngineReference::operator=(const QDeclarativeDebugEngineReference &o) -{ - m_debugId = o.m_debugId; m_name = o.m_name; - return *this; -} - -int QDeclarativeDebugEngineReference::debugId() const -{ - return m_debugId; -} - -QString QDeclarativeDebugEngineReference::name() const -{ - return m_name; -} - -QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference() - : m_debugId(-1), m_contextDebugId(-1) -{ -} - -QDeclarativeDebugObjectReference::QDeclarativeDebugObjectReference(int debugId) - : 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) -{ -} - -QDeclarativeDebugObjectReference & -QDeclarativeDebugObjectReference::operator=(const QDeclarativeDebugObjectReference &o) -{ - m_debugId = o.m_debugId; m_class = o.m_class; m_idString = o.m_idString; - m_name = o.m_name; m_source = o.m_source; m_contextDebugId = o.m_contextDebugId; - m_properties = o.m_properties; m_children = o.m_children; - return *this; -} - -int QDeclarativeDebugObjectReference::debugId() const -{ - return m_debugId; -} - -QString QDeclarativeDebugObjectReference::className() const -{ - return m_class; -} - -QString QDeclarativeDebugObjectReference::idString() const -{ - return m_idString; -} - -QString QDeclarativeDebugObjectReference::name() const -{ - return m_name; -} - -QDeclarativeDebugFileReference QDeclarativeDebugObjectReference::source() const -{ - return m_source; -} - -int QDeclarativeDebugObjectReference::contextDebugId() const -{ - return m_contextDebugId; -} - -QList<QDeclarativeDebugPropertyReference> QDeclarativeDebugObjectReference::properties() const -{ - return m_properties; -} - -QList<QDeclarativeDebugObjectReference> QDeclarativeDebugObjectReference::children() const -{ - return m_children; -} - -QDeclarativeDebugContextReference::QDeclarativeDebugContextReference() - : 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) -{ -} - -QDeclarativeDebugContextReference &QDeclarativeDebugContextReference::operator=(const QDeclarativeDebugContextReference &o) -{ - m_debugId = o.m_debugId; m_name = o.m_name; m_objects = o.m_objects; - m_contexts = o.m_contexts; - return *this; -} - -int QDeclarativeDebugContextReference::debugId() const -{ - return m_debugId; -} - -QString QDeclarativeDebugContextReference::name() const -{ - return m_name; -} - -QList<QDeclarativeDebugObjectReference> QDeclarativeDebugContextReference::objects() const -{ - return m_objects; -} - -QList<QDeclarativeDebugContextReference> QDeclarativeDebugContextReference::contexts() const -{ - return m_contexts; -} - -QDeclarativeDebugFileReference::QDeclarativeDebugFileReference() - : 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) -{ -} - -QDeclarativeDebugFileReference &QDeclarativeDebugFileReference::operator=(const QDeclarativeDebugFileReference &o) -{ - m_url = o.m_url; m_lineNumber = o.m_lineNumber; m_columnNumber = o.m_columnNumber; - return *this; -} - -QUrl QDeclarativeDebugFileReference::url() const -{ - return m_url; -} - -void QDeclarativeDebugFileReference::setUrl(const QUrl &u) -{ - m_url = u; -} - -int QDeclarativeDebugFileReference::lineNumber() const -{ - return m_lineNumber; -} - -void QDeclarativeDebugFileReference::setLineNumber(int l) -{ - m_lineNumber = l; -} - -int QDeclarativeDebugFileReference::columnNumber() const -{ - return m_columnNumber; -} - -void QDeclarativeDebugFileReference::setColumnNumber(int c) -{ - m_columnNumber = c; -} - -QDeclarativeDebugPropertyReference::QDeclarativeDebugPropertyReference() - : 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) -{ -} - -QDeclarativeDebugPropertyReference &QDeclarativeDebugPropertyReference::operator=(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; - return *this; -} - -int QDeclarativeDebugPropertyReference::objectDebugId() const -{ - return m_objectDebugId; -} - -QString QDeclarativeDebugPropertyReference::name() const -{ - return m_name; -} - -QString QDeclarativeDebugPropertyReference::valueTypeName() const -{ - return m_valueTypeName; -} - -QVariant QDeclarativeDebugPropertyReference::value() const -{ - return m_value; -} - -QString QDeclarativeDebugPropertyReference::binding() const -{ - return m_binding; -} - -bool QDeclarativeDebugPropertyReference::hasNotifySignal() const -{ - return m_hasNotifySignal; -} - -QT_END_NAMESPACE - diff --git a/src/declarative/debugger/qdeclarativeenginedebug_p.h b/src/declarative/debugger/qdeclarativeenginedebug_p.h deleted file mode 100644 index 5ca2987da3..0000000000 --- a/src/declarative/debugger/qdeclarativeenginedebug_p.h +++ /dev/null @@ -1,397 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 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> -#include <QtCore/qvariant.h> - -#include <private/qdeclarativeglobal_p.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeDebugConnection; -class QDeclarativeDebugWatch; -class QDeclarativeDebugPropertyWatch; -class QDeclarativeDebugObjectExpressionWatch; -class QDeclarativeDebugEnginesQuery; -class QDeclarativeDebugRootContextQuery; -class QDeclarativeDebugObjectQuery; -class QDeclarativeDebugExpressionQuery; -class QDeclarativeDebugPropertyReference; -class QDeclarativeDebugContextReference; -class QDeclarativeDebugObjectReference; -class QDeclarativeDebugFileReference; -class QDeclarativeDebugEngineReference; -class QDeclarativeEngineDebugPrivate; -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeEngineDebug : public QObject -{ - Q_OBJECT -public: - enum State { NotConnected, Unavailable, Enabled }; - - explicit QDeclarativeEngineDebug(QDeclarativeDebugConnection *, QObject * = 0); - ~QDeclarativeEngineDebug(); - - State state() const; - - QDeclarativeDebugPropertyWatch *addWatch(const QDeclarativeDebugPropertyReference &, - QObject *parent = 0); - QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugContextReference &, const QString &, - QObject *parent = 0); - QDeclarativeDebugObjectExpressionWatch *addWatch(const QDeclarativeDebugObjectReference &, const QString &, - QObject *parent = 0); - QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugObjectReference &, - QObject *parent = 0); - QDeclarativeDebugWatch *addWatch(const QDeclarativeDebugFileReference &, - 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); - 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); - bool resetBindingForObject(int objectDebugId, const QString &propertyName); - bool setMethodBody(int objectDebugId, const QString &methodName, const QString &methodBody); - -Q_SIGNALS: - void newObjects(); - void stateChanged(State state); - -private: - Q_DECLARE_PRIVATE(QDeclarativeEngineDebug) -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugWatch : public QObject -{ - Q_OBJECT -public: - enum State { Waiting, Active, Inactive, Dead }; - - QDeclarativeDebugWatch(QObject *); - ~QDeclarativeDebugWatch(); - - int queryId() const; - int objectDebugId() const; - State state() const; - -Q_SIGNALS: - void stateChanged(QDeclarativeDebugWatch::State); - //void objectChanged(int, const QDeclarativeDebugObjectReference &); - //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 QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - void setState(State); - State m_state; - int m_queryId; - QDeclarativeEngineDebug *m_client; - int m_objectDebugId; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugPropertyWatch : public QDeclarativeDebugWatch -{ - Q_OBJECT -public: - QDeclarativeDebugPropertyWatch(QObject *parent); - - QString name() const; - -private: - friend class QDeclarativeEngineDebug; - QString m_name; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectExpressionWatch : public QDeclarativeDebugWatch -{ - Q_OBJECT -public: - QDeclarativeDebugObjectExpressionWatch(QObject *parent); - - QString expression() const; - -private: - friend class QDeclarativeEngineDebug; - QString m_expr; - int m_debugId; -}; - - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugQuery : public QObject -{ - Q_OBJECT -public: - enum State { Waiting, Error, Completed }; - - State state() const; - bool isWaiting() const; - -Q_SIGNALS: - void stateChanged(QDeclarativeDebugQuery::State); - -protected: - QDeclarativeDebugQuery(QObject *); - -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - void setState(State); - State m_state; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugFileReference -{ -public: - QDeclarativeDebugFileReference(); - QDeclarativeDebugFileReference(const QDeclarativeDebugFileReference &); - QDeclarativeDebugFileReference &operator=(const QDeclarativeDebugFileReference &); - - QUrl url() const; - void setUrl(const QUrl &); - int lineNumber() const; - void setLineNumber(int); - int columnNumber() const; - void setColumnNumber(int); - -private: - friend class QDeclarativeEngineDebugPrivate; - QUrl m_url; - int m_lineNumber; - int m_columnNumber; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEngineReference -{ -public: - QDeclarativeDebugEngineReference(); - QDeclarativeDebugEngineReference(int); - QDeclarativeDebugEngineReference(const QDeclarativeDebugEngineReference &); - QDeclarativeDebugEngineReference &operator=(const QDeclarativeDebugEngineReference &); - - int debugId() const; - QString name() const; - -private: - friend class QDeclarativeEngineDebugPrivate; - int m_debugId; - QString m_name; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectReference -{ -public: - QDeclarativeDebugObjectReference(); - QDeclarativeDebugObjectReference(int); - QDeclarativeDebugObjectReference(const QDeclarativeDebugObjectReference &); - QDeclarativeDebugObjectReference &operator=(const QDeclarativeDebugObjectReference &); - - int debugId() const; - QString className() const; - QString idString() const; - QString name() const; - - QDeclarativeDebugFileReference source() const; - int contextDebugId() const; - - QList<QDeclarativeDebugPropertyReference> properties() const; - QList<QDeclarativeDebugObjectReference> children() const; - -private: - friend class QDeclarativeEngineDebugPrivate; - int m_debugId; - QString m_class; - QString m_idString; - QString m_name; - QDeclarativeDebugFileReference m_source; - int m_contextDebugId; - QList<QDeclarativeDebugPropertyReference> m_properties; - QList<QDeclarativeDebugObjectReference> m_children; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugContextReference -{ -public: - QDeclarativeDebugContextReference(); - QDeclarativeDebugContextReference(const QDeclarativeDebugContextReference &); - QDeclarativeDebugContextReference &operator=(const QDeclarativeDebugContextReference &); - - int debugId() const; - QString name() const; - - QList<QDeclarativeDebugObjectReference> objects() const; - QList<QDeclarativeDebugContextReference> contexts() const; - -private: - friend class QDeclarativeEngineDebugPrivate; - int m_debugId; - QString m_name; - QList<QDeclarativeDebugObjectReference> m_objects; - QList<QDeclarativeDebugContextReference> m_contexts; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugPropertyReference -{ -public: - QDeclarativeDebugPropertyReference(); - QDeclarativeDebugPropertyReference(const QDeclarativeDebugPropertyReference &); - QDeclarativeDebugPropertyReference &operator=(const QDeclarativeDebugPropertyReference &); - - int objectDebugId() const; - QString name() const; - QVariant value() const; - QString valueTypeName() const; - QString binding() const; - bool hasNotifySignal() const; - -private: - friend class QDeclarativeEngineDebugPrivate; - int m_objectDebugId; - QString m_name; - QVariant m_value; - QString m_valueTypeName; - QString m_binding; - bool m_hasNotifySignal; -}; - - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugEnginesQuery : public QDeclarativeDebugQuery -{ - Q_OBJECT -public: - virtual ~QDeclarativeDebugEnginesQuery(); - QList<QDeclarativeDebugEngineReference> engines() const; -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - QDeclarativeDebugEnginesQuery(QObject *); - QDeclarativeEngineDebug *m_client; - int m_queryId; - QList<QDeclarativeDebugEngineReference> m_engines; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugRootContextQuery : public QDeclarativeDebugQuery -{ - Q_OBJECT -public: - virtual ~QDeclarativeDebugRootContextQuery(); - QDeclarativeDebugContextReference rootContext() const; -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - QDeclarativeDebugRootContextQuery(QObject *); - QDeclarativeEngineDebug *m_client; - int m_queryId; - QDeclarativeDebugContextReference m_context; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugObjectQuery : public QDeclarativeDebugQuery -{ - Q_OBJECT -public: - virtual ~QDeclarativeDebugObjectQuery(); - QDeclarativeDebugObjectReference object() const; -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - QDeclarativeDebugObjectQuery(QObject *); - QDeclarativeEngineDebug *m_client; - int m_queryId; - QDeclarativeDebugObjectReference m_object; - -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeDebugExpressionQuery : public QDeclarativeDebugQuery -{ - Q_OBJECT -public: - virtual ~QDeclarativeDebugExpressionQuery(); - QVariant expression() const; - QVariant result() const; -private: - friend class QDeclarativeEngineDebug; - friend class QDeclarativeEngineDebugPrivate; - QDeclarativeDebugExpressionQuery(QObject *); - QDeclarativeEngineDebug *m_client; - int m_queryId; - QVariant m_expr; - QVariant m_result; -}; - -QT_END_NAMESPACE - -Q_DECLARE_METATYPE(QDeclarativeDebugEngineReference) -Q_DECLARE_METATYPE(QDeclarativeDebugObjectReference) -Q_DECLARE_METATYPE(QDeclarativeDebugContextReference) -Q_DECLARE_METATYPE(QDeclarativeDebugPropertyReference) - -QT_END_HEADER - -#endif // QDECLARATIVEENGINEDEBUG_H diff --git a/src/declarative/debugger/qdeclarativeenginedebugservice.cpp b/src/declarative/debugger/qdeclarativeenginedebugservice.cpp deleted file mode 100644 index 4943959c33..0000000000 --- a/src/declarative/debugger/qdeclarativeenginedebugservice.cpp +++ /dev/null @@ -1,733 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qdeclarativeenginedebugservice_p.h" - -#include "qdeclarativedebugstatesdelegate_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 <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"), 1, parent), - m_watch(new QDeclarativeWatcher(this)), - m_statesDelegate(0) -{ - QObject::connect(m_watch, SIGNAL(propertyChanged(int,int,QMetaProperty,QVariant)), - this, SLOT(propertyChanged(int,int,QMetaProperty,QVariant))); - - registerService(); -} - -QDeclarativeEngineDebugService::~QDeclarativeEngineDebugService() -{ - delete m_statesDelegate; -} - -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(); - - //QObject * is not streamable. - //Convert all such instances to a String value - - 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 (value.type() == QVariant::Map) { - QVariantMap contents; - QMapIterator<QString, QVariant> i(value.toMap()); - while (i.hasNext()) { - i.next(); - contents.insert(i.key(), valueContents(i.value())); - } - return contents; - } - - if (QDeclarativeValueTypeFactory::isValueType(userType)) - return value; - - 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) -{ - if (m_statesDelegate) - m_statesDelegate->buildStatesList(ctxt, cleanList); -} - -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 = 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) -{ - QMetaObject::invokeMethod(this, "processMessage", Qt::QueuedConnection, Q_ARG(QByteArray, message)); -} - -void QDeclarativeEngineDebugService::processMessage(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, - int column) -{ - QObject *object = objectForId(objectId); - QDeclarativeContext *context = qmlContext(object); - - if (object && context) { - QDeclarativeProperty property(object, propertyName, context); - if (property.isValid()) { - - bool inBaseState = true; - if (m_statesDelegate) { - m_statesDelegate->updateBinding(context, property, expression, isLiteralValue, - filename, line, column, &inBaseState); - } - - 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, column); - } else if (property.isProperty()) { - QDeclarativeBinding *binding = new QDeclarativeBinding(expression.toString(), object, context); - binding->setTarget(property); - binding->setSourceLocation(filename, line, column); - 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 - bool ok = false; - if (m_statesDelegate) - ok = m_statesDelegate->setBindingForInvalidProperty(object, propertyName, expression, isLiteralValue); - if (!ok) - 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 (m_statesDelegate) - m_statesDelegate->resetBindingForInvalidProperty(object, 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; - - QDeclarativePropertyData dummy; - QDeclarativePropertyData *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); -} - -void QDeclarativeEngineDebugService::setStatesDelegate(QDeclarativeDebugStatesDelegate *delegate) -{ - m_statesDelegate = delegate; -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativeenginedebugservice_p.h b/src/declarative/debugger/qdeclarativeenginedebugservice_p.h deleted file mode 100644 index d252654492..0000000000 --- a/src/declarative/debugger/qdeclarativeenginedebugservice_p.h +++ /dev/null @@ -1,136 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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> - -QT_BEGIN_NAMESPACE - -class QDeclarativeEngine; -class QDeclarativeContext; -class QDeclarativeWatcher; -class QDataStream; -class QDeclarativeDebugStatesDelegate; - -class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeEngineDebugService : public QDeclarativeDebugService -{ - Q_OBJECT -public: - QDeclarativeEngineDebugService(QObject * = 0); - ~QDeclarativeEngineDebugService(); - - 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 *); - - void setStatesDelegate(QDeclarativeDebugStatesDelegate *); - - static QDeclarativeEngineDebugService *instance(); - -protected: - virtual void messageReceived(const QByteArray &); - -private Q_SLOTS: - void processMessage(const QByteArray &msg); - 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); - 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, int column = 0); - void resetBinding(int objectId, const QString &propertyName); - void setMethodBody(int objectId, const QString &method, const QString &body); - - QList<QDeclarativeEngine *> m_engines; - QDeclarativeWatcher *m_watch; - QDeclarativeDebugStatesDelegate *m_statesDelegate; -}; -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 deleted file mode 100644 index e109fc015e..0000000000 --- a/src/declarative/debugger/qdeclarativeinspectorinterface_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 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 <private/qdeclarativeglobal_p.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class Q_DECLARATIVE_EXPORT QDeclarativeInspectorInterface -{ -public: - QDeclarativeInspectorInterface() {} - virtual ~QDeclarativeInspectorInterface() {} - - virtual bool canHandleView(QObject *view) = 0; - - virtual void activate(QObject *view) = 0; - virtual void deactivate() = 0; - - virtual void clientMessage(const QByteArray &message) = 0; -}; - -Q_DECLARE_INTERFACE(QDeclarativeInspectorInterface, "com.trolltech.Qt.QDeclarativeInspectorInterface/1.0") - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEINSPECTORINTERFACE_H diff --git a/src/declarative/debugger/qdeclarativeinspectorservice.cpp b/src/declarative/debugger/qdeclarativeinspectorservice.cpp deleted file mode 100644 index 94b04985ba..0000000000 --- a/src/declarative/debugger/qdeclarativeinspectorservice.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qdeclarativeinspectorservice_p.h" -#include "qdeclarativeinspectorinterface_p.h" -#include "qdeclarativedebugserver_p.h" - -#include <QtCore/QCoreApplication> -#include <QtCore/QDebug> -#include <QtCore/QDir> -#include <QtCore/QPluginLoader> - -// print detailed information about loading of plugins -DEFINE_BOOL_CONFIG_OPTION(qmlDebugVerbose, QML_DEBUGGER_VERBOSE) - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QDeclarativeInspectorService, serviceInstance) - -QDeclarativeInspectorService::QDeclarativeInspectorService() - : QDeclarativeDebugService(QLatin1String("QDeclarativeObserverMode"), 1) - , m_currentInspectorPlugin(0) -{ - registerService(); -} - -QDeclarativeInspectorService *QDeclarativeInspectorService::instance() -{ - return serviceInstance(); -} - -void QDeclarativeInspectorService::addView(QObject *view) -{ - m_views.append(view); - updateState(); -} - -void QDeclarativeInspectorService::removeView(QObject *view) -{ - m_views.removeAll(view); - updateState(); -} - -void QDeclarativeInspectorService::sendMessage(const QByteArray &message) -{ - if (state() != Enabled) - return; - - QDeclarativeDebugService::sendMessage(message); -} - -void QDeclarativeInspectorService::stateChanged(State /*state*/) -{ - QMetaObject::invokeMethod(this, "updateState", Qt::QueuedConnection); -} - -void QDeclarativeInspectorService::updateState() -{ - if (m_views.isEmpty()) { - if (m_currentInspectorPlugin) { - m_currentInspectorPlugin->deactivate(); - m_currentInspectorPlugin = 0; - } - return; - } - - if (state() == Enabled) { - if (m_inspectorPlugins.isEmpty()) - loadInspectorPlugins(); - - if (m_inspectorPlugins.isEmpty()) { - qWarning() << "QDeclarativeInspector: No plugins found."; - QDeclarativeDebugServer::instance()->removeService(this); - return; - } - - foreach (QDeclarativeInspectorInterface *inspector, m_inspectorPlugins) { - if (inspector->canHandleView(m_views.first())) { - m_currentInspectorPlugin = inspector; - break; - } - } - - if (!m_currentInspectorPlugin) { - qWarning() << "QDeclarativeInspector: No plugin available for view '" << m_views.first()->metaObject()->className() << "'."; - return; - } - m_currentInspectorPlugin->activate(m_views.first()); - } else { - if (m_currentInspectorPlugin) { - m_currentInspectorPlugin->deactivate(); - m_currentInspectorPlugin = 0; - } - } -} - -void QDeclarativeInspectorService::messageReceived(const QByteArray &message) -{ - QMetaObject::invokeMethod(this, "processMessage", Qt::QueuedConnection, Q_ARG(QByteArray, message)); -} - -void QDeclarativeInspectorService::processMessage(const QByteArray &message) -{ - if (m_currentInspectorPlugin) - m_currentInspectorPlugin->clientMessage(message); -} - -void QDeclarativeInspectorService::loadInspectorPlugins() -{ - QStringList pluginCandidates; - const QStringList paths = QCoreApplication::libraryPaths(); - foreach (const QString &libPath, paths) { - const QDir dir(libPath + QLatin1String("/qmltooling")); - if (dir.exists()) - foreach (const QString &pluginPath, dir.entryList(QDir::Files)) - pluginCandidates << dir.absoluteFilePath(pluginPath); - } - - foreach (const QString &pluginPath, pluginCandidates) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeInspector: Trying to load plugin " << pluginPath << "..."; - - QPluginLoader loader(pluginPath); - if (!loader.load()) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeInspector: Error while loading: " << loader.errorString(); - - continue; - } - - QDeclarativeInspectorInterface *inspector = - qobject_cast<QDeclarativeInspectorInterface*>(loader.instance()); - if (inspector) { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeInspector: Plugin successfully loaded."; - m_inspectorPlugins << inspector; - } else { - if (qmlDebugVerbose()) - qDebug() << "QDeclarativeInspector: Plugin does not implement interface QDeclarativeInspectorInterface."; - - loader.unload(); - } - } -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativeinspectorservice_p.h b/src/declarative/debugger/qdeclarativeinspectorservice_p.h deleted file mode 100644 index 7ed530adc0..0000000000 --- a/src/declarative/debugger/qdeclarativeinspectorservice_p.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 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 "qdeclarativedebugservice_p.h" -#include <private/qdeclarativeglobal_p.h> - -#include <QtCore/QList> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QDeclarativeInspectorInterface; - -class Q_DECLARATIVE_EXPORT QDeclarativeInspectorService : public QDeclarativeDebugService -{ - Q_OBJECT - -public: - QDeclarativeInspectorService(); - static QDeclarativeInspectorService *instance(); - - void addView(QObject *); - void removeView(QObject *); - - void sendMessage(const QByteArray &message); - -protected: - virtual void stateChanged(State state); - virtual void messageReceived(const QByteArray &); - -private slots: - void processMessage(const QByteArray &message); - void updateState(); - -private: - void loadInspectorPlugins(); - - QList<QObject*> m_views; - QDeclarativeInspectorInterface *m_currentInspectorPlugin; - QList<QDeclarativeInspectorInterface*> m_inspectorPlugins; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEINSPECTORSERVICE_H diff --git a/src/declarative/debugger/qdeclarativeprofilerservice.cpp b/src/declarative/debugger/qdeclarativeprofilerservice.cpp deleted file mode 100644 index 17ee3e5836..0000000000 --- a/src/declarative/debugger/qdeclarativeprofilerservice.cpp +++ /dev/null @@ -1,357 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qdeclarativeprofilerservice_p.h" - -#include <QtCore/qdatastream.h> -#include <QtCore/qurl.h> -#include <QtCore/qtimer.h> -#include <QtCore/qthread.h> -#include <QtCore/qcoreapplication.h> - -// this contains QUnifiedTimer -#include <private/qabstractanimation_p.h> - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QDeclarativeProfilerService, profilerInstance) - -QDeclarativeBindingProfiler::QDeclarativeBindingProfiler(const QString &url, int line, int column) -{ - QDeclarativeProfilerService::startRange(QDeclarativeProfilerService::Binding); - QDeclarativeProfilerService::rangeLocation(QDeclarativeProfilerService::Binding, url, line, column); -} - -QDeclarativeBindingProfiler::~QDeclarativeBindingProfiler() -{ - QDeclarativeProfilerService::endRange(QDeclarativeProfilerService::Binding); -} - -void QDeclarativeBindingProfiler::addDetail(const QString &details) -{ - QDeclarativeProfilerService::rangeData(QDeclarativeProfilerService::Binding, details); -} - -// convert to a QByteArray that can be sent to the debug client -// use of QDataStream can skew results -// (see tst_qdeclarativedebugtrace::trace() benchmark) -QByteArray QDeclarativeProfilerData::toByteArray() const -{ - QByteArray data; - //### using QDataStream is relatively expensive - QDataStream ds(&data, QIODevice::WriteOnly); - ds << time << messageType << detailType; - if (messageType == (int)QDeclarativeProfilerService::RangeData) - ds << detailData; - if (messageType == (int)QDeclarativeProfilerService::RangeLocation) - ds << detailData << line << column; - if (messageType == (int)QDeclarativeProfilerService::Event && - detailType == (int)QDeclarativeProfilerService::AnimationFrame) - ds << framerate << animationcount; - return data; -} - -QDeclarativeProfilerService::QDeclarativeProfilerService() - : QDeclarativeDebugService(QLatin1String("CanvasFrameRate"), 1), - m_enabled(false), m_messageReceived(false) -{ - m_timer.start(); - - if (registerService() == Enabled) { - // wait for first message indicating whether to trace or not - while (!m_messageReceived) - waitForMessage(); - - QUnifiedTimer::instance()->registerProfilerCallback( &animationFrame ); - } -} - -QDeclarativeProfilerService::~QDeclarativeProfilerService() -{ -} - -void QDeclarativeProfilerService::initialize() -{ - // just make sure that the service is properly registered - profilerInstance(); -} - -bool QDeclarativeProfilerService::startProfiling() -{ - return profilerInstance()->startProfilingImpl(); -} - -bool QDeclarativeProfilerService::stopProfiling() -{ - return profilerInstance()->stopProfilingImpl(); -} - -void QDeclarativeProfilerService::sendStartedProfilingMessage() -{ - profilerInstance()->sendStartedProfilingMessageImpl(); -} - -void QDeclarativeProfilerService::addEvent(EventType t) -{ - profilerInstance()->addEventImpl(t); -} - -void QDeclarativeProfilerService::startRange(RangeType t) -{ - profilerInstance()->startRangeImpl(t); -} - -void QDeclarativeProfilerService::rangeData(RangeType t, const QString &data) -{ - profilerInstance()->rangeDataImpl(t, data); -} - -void QDeclarativeProfilerService::rangeData(RangeType t, const QUrl &data) -{ - profilerInstance()->rangeDataImpl(t, data); -} - -void QDeclarativeProfilerService::rangeLocation(RangeType t, const QString &fileName, int line, int column) -{ - profilerInstance()->rangeLocationImpl(t, fileName, line, column); -} - -void QDeclarativeProfilerService::rangeLocation(RangeType t, const QUrl &fileName, int line, int column) -{ - profilerInstance()->rangeLocationImpl(t, fileName, line, column); -} - -void QDeclarativeProfilerService::endRange(RangeType t) -{ - profilerInstance()->endRangeImpl(t); -} - -void QDeclarativeProfilerService::animationFrame(qint64 delta) -{ - profilerInstance()->animationFrameImpl(delta); -} - -void QDeclarativeProfilerService::sendProfilingData() -{ - profilerInstance()->sendMessages(); -} - -bool QDeclarativeProfilerService::startProfilingImpl() -{ - bool success = false; - if (!profilingEnabled()) { - setProfilingEnabled(true); - sendStartedProfilingMessageImpl(); - success = true; - } - return success; -} - -bool QDeclarativeProfilerService::stopProfilingImpl() -{ - bool success = false; - if (profilingEnabled()) { - addEventImpl(EndTrace); - setProfilingEnabled(false); - success = true; - } - return success; -} - -void QDeclarativeProfilerService::sendStartedProfilingMessageImpl() -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData ed = {m_timer.nsecsElapsed(), (int)Event, (int)StartTrace, QString(), -1, -1, 0, 0}; - QDeclarativeDebugService::sendMessage(ed.toByteArray()); -} - -void QDeclarativeProfilerService::addEventImpl(EventType event) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData ed = {m_timer.nsecsElapsed(), (int)Event, (int)event, QString(), -1, -1, 0, 0}; - processMessage(ed); -} - -void QDeclarativeProfilerService::startRangeImpl(RangeType range) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeStart, (int)range, QString(), -1, -1, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::rangeDataImpl(RangeType range, const QString &rData) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeData, (int)range, rData, -1, -1, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::rangeDataImpl(RangeType range, const QUrl &rData) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeData, (int)range, rData.toString(QUrl::FormattingOption(0x100)), -1, -1, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::rangeLocationImpl(RangeType range, const QString &fileName, int line, int column) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeLocation, (int)range, fileName, line, column, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::rangeLocationImpl(RangeType range, const QUrl &fileName, int line, int column) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeLocation, (int)range, fileName.toString(QUrl::FormattingOption(0x100)), line, column, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::endRangeImpl(RangeType range) -{ - if (!QDeclarativeDebugService::isDebuggingEnabled() || !m_enabled) - return; - - QDeclarativeProfilerData rd = {m_timer.nsecsElapsed(), (int)RangeEnd, (int)range, QString(), -1, -1, 0, 0}; - processMessage(rd); -} - -void QDeclarativeProfilerService::animationFrameImpl(qint64 delta) -{ - Q_ASSERT(QDeclarativeDebugService::isDebuggingEnabled()); - if (!m_enabled) - return; - - int animCount = QUnifiedTimer::instance()->runningAnimationCount(); - - if (animCount > 0 && delta > 0) { - // trim fps to integer - int fps = 1000 / delta; - QDeclarativeProfilerData ed = {m_timer.nsecsElapsed(), (int)Event, (int)AnimationFrame, QString(), -1, -1, fps, animCount}; - processMessage(ed); - } -} - -/* - Either send the message directly, or queue up - a list of messages to send later (via sendMessages) -*/ -void QDeclarativeProfilerService::processMessage(const QDeclarativeProfilerData &message) -{ - QMutexLocker locker(&m_mutex); - m_data.append(message); -} - -bool QDeclarativeProfilerService::profilingEnabled() -{ - return m_enabled; -} - -void QDeclarativeProfilerService::setProfilingEnabled(bool enable) -{ - m_enabled = enable; -} - -/* - Send the messages queued up by processMessage -*/ -void QDeclarativeProfilerService::sendMessages() -{ - QMutexLocker locker(&m_mutex); - QList<QByteArray> messages; - for (int i = 0; i < m_data.count(); ++i) - messages << m_data.at(i).toByteArray(); - m_data.clear(); - - //indicate completion - QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); - ds << (qint64)-1 << (int)Complete; - messages << data; - - QDeclarativeDebugService::sendMessages(messages); -} - -void QDeclarativeProfilerService::stateAboutToBeChanged(QDeclarativeDebugService::State newState) -{ - if (state() == newState) - return; - - if (state() == Enabled - && m_enabled) { - stopProfilingImpl(); - sendMessages(); - } -} - -void QDeclarativeProfilerService::messageReceived(const QByteArray &message) -{ - QByteArray rwData = message; - QDataStream stream(&rwData, QIODevice::ReadOnly); - - bool enabled; - stream >> enabled; - - m_messageReceived = true; - - if (enabled) { - startProfilingImpl(); - } else { - if (stopProfilingImpl()) - sendMessages(); - } -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qdeclarativeprofilerservice_p.h b/src/declarative/debugger/qdeclarativeprofilerservice_p.h deleted file mode 100644 index d29690b6d6..0000000000 --- a/src/declarative/debugger/qdeclarativeprofilerservice_p.h +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QDECLARATIVEPROFILERSERVICE_P_H -#define QDECLARATIVEPROFILERSERVICE_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> -#include <QtCore/qmutex.h> -#include <QtCore/qvector.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -struct Q_AUTOTEST_EXPORT QDeclarativeProfilerData -{ - qint64 time; - int messageType; - int detailType; - - //### - QString detailData; //used by RangeData and RangeLocation - int line; //used by RangeLocation - int column; //used by RangeLocation - int framerate; //used by animation events - int animationcount; //used by animation events - - QByteArray toByteArray() const; -}; - -Q_DECLARE_TYPEINFO(QDeclarativeProfilerData, Q_MOVABLE_TYPE); - -class QUrl; -class QDeclarativeEngine; - -// RAII -class Q_AUTOTEST_EXPORT QDeclarativeBindingProfiler { -public: - QDeclarativeBindingProfiler(const QString &url, int line, int column); - ~QDeclarativeBindingProfiler(); - void addDetail(const QString &details); -}; - -class Q_DECLARATIVE_EXPORT QDeclarativeProfilerService : public QDeclarativeDebugService -{ -public: - enum Message { - Event, - RangeStart, - RangeData, - RangeLocation, - RangeEnd, - Complete, // end of transmission - - MaximumMessage - }; - - enum EventType { - FramePaint, - Mouse, - Key, - AnimationFrame, - EndTrace, - StartTrace, - - MaximumEventType - }; - - enum RangeType { - Painting, - Compiling, - Creating, - Binding, //running a binding - HandlingSignal, //running a signal handler - - MaximumRangeType - }; - - static void initialize(); - - static bool startProfiling(); - static bool stopProfiling(); - static void sendStartedProfilingMessage(); - static void addEvent(EventType); - static void startRange(RangeType); - static void rangeData(RangeType, const QString &); - static void rangeData(RangeType, const QUrl &); - static void rangeLocation(RangeType, const QString &, int, int); - static void rangeLocation(RangeType, const QUrl &, int, int); - static void endRange(RangeType); - static void animationFrame(qint64); - - static void sendProfilingData(); - - QDeclarativeProfilerService(); - ~QDeclarativeProfilerService(); - -protected: - virtual void stateAboutToBeChanged(State state); - virtual void messageReceived(const QByteArray &); - -private: - bool startProfilingImpl(); - bool stopProfilingImpl(); - void sendStartedProfilingMessageImpl(); - void addEventImpl(EventType); - void startRangeImpl(RangeType); - void rangeDataImpl(RangeType, const QString &); - void rangeDataImpl(RangeType, const QUrl &); - void rangeLocationImpl(RangeType, const QString &, int, int); - void rangeLocationImpl(RangeType, const QUrl &, int, int); - void endRangeImpl(RangeType); - void animationFrameImpl(qint64); - - bool profilingEnabled(); - void setProfilingEnabled(bool enable); - void sendMessages(); - void processMessage(const QDeclarativeProfilerData &); - -private: - QElapsedTimer m_timer; - bool m_enabled; - bool m_messageReceived; - QVector<QDeclarativeProfilerData> m_data; - QMutex m_mutex; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QDECLARATIVEPROFILERSERVICE_P_H - diff --git a/src/declarative/debugger/qpacketprotocol.cpp b/src/declarative/debugger/qpacketprotocol.cpp deleted file mode 100644 index fa5d676e0a..0000000000 --- a/src/declarative/debugger/qpacketprotocol.cpp +++ /dev/null @@ -1,550 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qpacketprotocol_p.h" - -#include <QtCore/QBuffer> -#include <QtCore/QElapsedTimer> - -QT_BEGIN_NAMESPACE - -static const unsigned int MAX_PACKET_SIZE = 0x7FFFFFFF; - -/*! - \class QPacketProtocol - \internal - - \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 - fragmented transports such as TCP and UDP. - - As transmission boundaries are not respected, sending packets over protocols - like TCP frequently involves "stitching" them back together at the receiver. - QPacketProtocol makes this easier by performing this task for you. Packet - data sent using QPacketProtocol is prepended with a 4-byte size header - allowing the receiving QPacketProtocol to buffer the packet internally until - it has all been received. QPacketProtocol does not perform any sanity - checking on the size or on the data, so this class should only be used in - prototyping or trusted situations where DOS attacks are unlikely. - - QPacketProtocol does not perform any communications itself. Instead it can - operate on any QIODevice that supports the QIODevice::readyRead() signal. A - logical "packet" is encapsulated by the companion QPacket class. The - following example shows two ways to send data using QPacketProtocol. The - transmitted data is equivalent in both. - - \code - QTcpSocket socket; - // ... connect socket ... - - QPacketProtocol protocol(&socket); - - // Send packet the quick way - protocol.send() << "Hello world" << 123; - - // Send packet the longer way - QPacket packet; - packet << "Hello world" << 123; - protocol.send(packet); - \endcode - - Likewise, the following shows how to read data from QPacketProtocol, assuming - that the QPacketProtocol::readyRead() signal has been emitted. - - \code - // ... QPacketProtocol::readyRead() is emitted ... - - int a; - QByteArray b; - - // Receive packet the quick way - protocol.read() >> a >> b; - - // Receive packet the longer way - QPacket packet = protocol.read(); - p >> a >> b; - \endcode - - \ingroup io - \sa QPacket -*/ - -class QPacketProtocolPrivate : public QObject -{ - Q_OBJECT -public: - QPacketProtocolPrivate(QPacketProtocol *parent, QIODevice *_dev) - : QObject(parent), inProgressSize(-1), maxPacketSize(MAX_PACKET_SIZE), - waitingForPacket(false), dev(_dev) - { - Q_ASSERT(4 == sizeof(qint32)); - - QObject::connect(this, SIGNAL(readyRead()), - parent, SIGNAL(readyRead())); - QObject::connect(this, SIGNAL(packetWritten()), - parent, SIGNAL(packetWritten())); - QObject::connect(this, SIGNAL(invalidPacket()), - parent, SIGNAL(invalidPacket())); - QObject::connect(dev, SIGNAL(readyRead()), - this, SLOT(readyToRead())); - QObject::connect(dev, SIGNAL(aboutToClose()), - this, SLOT(aboutToClose())); - QObject::connect(dev, SIGNAL(bytesWritten(qint64)), - this, SLOT(bytesWritten(qint64))); - } - -Q_SIGNALS: - void readyRead(); - void packetWritten(); - void invalidPacket(); - -public Q_SLOTS: - void aboutToClose() - { - inProgress.clear(); - sendingPackets.clear(); - inProgressSize = -1; - } - - void bytesWritten(qint64 bytes) - { - Q_ASSERT(!sendingPackets.isEmpty()); - - while (bytes) { - if (sendingPackets.at(0) > bytes) { - sendingPackets[0] -= bytes; - bytes = 0; - } else { - bytes -= sendingPackets.at(0); - sendingPackets.removeFirst(); - emit packetWritten(); - } - } - } - - void readyToRead() - { - while (true) { - // Need to get trailing data - if (-1 == inProgressSize) { - // We need a size header of sizeof(qint32) - if (sizeof(qint32) > (uint)dev->bytesAvailable()) - return; - - // Read size header - int read = dev->read((char *)&inProgressSize, sizeof(qint32)); - Q_ASSERT(read == sizeof(qint32)); - Q_UNUSED(read); - - // Check sizing constraints - if (inProgressSize > maxPacketSize) { - QObject::disconnect(dev, SIGNAL(readyRead()), - this, SLOT(readyToRead())); - QObject::disconnect(dev, SIGNAL(aboutToClose()), - this, SLOT(aboutToClose())); - QObject::disconnect(dev, SIGNAL(bytesWritten(qint64)), - this, SLOT(bytesWritten(qint64))); - dev = 0; - emit invalidPacket(); - return; - } - - inProgressSize -= sizeof(qint32); - } else { - inProgress.append(dev->read(inProgressSize - inProgress.size())); - - if (inProgressSize == inProgress.size()) { - // Packet has arrived! - packets.append(inProgress); - inProgressSize = -1; - inProgress.clear(); - - waitingForPacket = false; - emit readyRead(); - } else - return; - } - } - } - -public: - QList<qint64> sendingPackets; - QList<QByteArray> packets; - QByteArray inProgress; - qint32 inProgressSize; - qint32 maxPacketSize; - bool waitingForPacket; - 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)) -{ - Q_ASSERT(dev); -} - -/*! - Destroys the QPacketProtocol instance. - */ -QPacketProtocol::~QPacketProtocol() -{ -} - -/*! - Returns the maximum packet size allowed. By default this is - 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. - - \sa QPacketProtocol::setMaximumPacketSize() - */ -qint32 QPacketProtocol::maximumPacketSize() const -{ - return d->maxPacketSize; -} - -/*! - Sets the maximum allowable packet size to \a max. - - \sa QPacketProtocol::maximumPacketSize() - */ -qint32 QPacketProtocol::setMaximumPacketSize(qint32 max) -{ - if (max > (signed)sizeof(qint32)) - d->maxPacketSize = max; - return d->maxPacketSize; -} - -/*! - Returns a streamable object that is transmitted on destruction. For example - - \code - protocol.send() << "Hello world" << 123; - \endcode - - will send a packet containing "Hello world" and 123. To construct more - complex packets, explicitly construct a QPacket instance. - */ -QPacketAutoSend QPacketProtocol::send() -{ - return QPacketAutoSend(this); -} - -/*! - \fn void QPacketProtocol::send(const QPacket & packet) - - Transmit the \a packet. - */ -void QPacketProtocol::send(const QPacket & p) -{ - if (p.b.isEmpty()) - return; // We don't send empty packets - - qint64 sendSize = p.b.size() + sizeof(qint32); - - d->sendingPackets.append(sendSize); - qint32 sendSize32 = sendSize; - qint64 writeBytes = d->dev->write((char *)&sendSize32, sizeof(qint32)); - Q_ASSERT(writeBytes == sizeof(qint32)); - writeBytes = d->dev->write(p.b); - Q_ASSERT(writeBytes == p.b.size()); -} - -/*! - Returns the number of received packets yet to be read. - */ -qint64 QPacketProtocol::packetsAvailable() const -{ - return d->packets.count(); -} - -/*! - Discard any unread packets. - */ -void QPacketProtocol::clear() -{ - d->packets.clear(); -} - -/*! - Return the next unread packet, or an invalid QPacket instance if no packets - are available. This method does NOT block. - */ -QPacket QPacketProtocol::read() -{ - if (0 == d->packets.count()) - return QPacket(); - - QPacket rv(d->packets.at(0)); - d->packets.removeFirst(); - return rv; -} - -/* - Returns the difference between msecs and elapsed. If msecs is -1, - however, -1 is returned. -*/ -static int qt_timeout_value(int msecs, int elapsed) -{ - if (msecs == -1) - return -1; - - int timeout = msecs - elapsed; - return timeout < 0 ? 0 : timeout; -} - -/*! - This function locks until a new packet is available for reading and the - \l{QIODevice::}{readyRead()} signal has been emitted. The function - will timeout after \a msecs milliseconds; the default timeout is - 30000 milliseconds. - - The function returns true if the readyRead() signal is emitted and - there is new data available for reading; otherwise it returns false - (if an error occurred or the operation timed out). - */ - -bool QPacketProtocol::waitForReadyRead(int msecs) -{ - if (!d->packets.isEmpty()) - return true; - - QElapsedTimer stopWatch; - stopWatch.start(); - - d->waitingForPacket = true; - do { - if (!d->dev->waitForReadyRead(msecs)) - return false; - if (!d->waitingForPacket) - return true; - msecs = qt_timeout_value(msecs, stopWatch.elapsed()); - } while (true); -} - -/*! - Return the QIODevice passed to the QPacketProtocol constructor. -*/ -QIODevice *QPacketProtocol::device() -{ - return d->dev; -} - -/*! - \fn void QPacketProtocol::readyRead() - - Emitted whenever a new packet is received. Applications may use - QPacketProtocol::read() to retrieve this packet. - */ - -/*! - \fn void QPacketProtocol::invalidPacket() - - A packet larger than the maximum allowable packet size was received. The - packet will be discarded and, as it indicates corruption in the protocol, no - further packets will be received. - */ - -/*! - \fn void QPacketProtocol::packetWritten() - - Emitted each time a packet is completing written to the device. This signal - may be used for communications flow control. - */ - -/*! - \class QPacket - \internal - - \brief The QPacket class encapsulates an unfragmentable packet of data to be - transmitted by QPacketProtocol. - - The QPacket class works together with QPacketProtocol to make it simple to - send arbitrary sized data "packets" across fragmented transports such as TCP - and UDP. - - QPacket provides a QDataStream interface to an unfragmentable packet. - Applications should construct a QPacket, propagate it with data and then - transmit it over a QPacketProtocol instance. For example: - \code - QPacketProtocol protocol(...); - - QPacket myPacket; - myPacket << "Hello world!" << 123; - protocol.send(myPacket); - \endcode - - As long as both ends of the connection are using the QPacketProtocol class, - the data within this packet will be delivered unfragmented at the other end, - ready for extraction. - - \code - QByteArray greeting; - int count; - - QPacket myPacket = protocol.read(); - - myPacket >> greeting >> count; - \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 - result in undefined behavior. - - \ingroup io - \sa QPacketProtocol - */ - -/*! - Constructs an empty write-only packet. - */ -QPacket::QPacket() - : QDataStream(), buf(0) -{ - buf = new QBuffer(&b); - buf->open(QIODevice::WriteOnly); - setDevice(buf); - setVersion(QDataStream::Qt_4_7); -} - -/*! - Destroys the QPacket instance. - */ -QPacket::~QPacket() -{ - if (buf) { - delete buf; - buf = 0; - } -} - -/*! - Creates a copy of \a other. The initial stream positions are shared, but the - two packets are otherwise independent. - */ -QPacket::QPacket(const QPacket & other) - : QDataStream(), b(other.b), buf(0) -{ - buf = new QBuffer(&b); - buf->open(other.buf->openMode()); - setDevice(buf); -} - -/*! - \internal - */ -QPacket::QPacket(const QByteArray & ba) - : QDataStream(), b(ba), buf(0) -{ - buf = new QBuffer(&b); - buf->open(QIODevice::ReadOnly); - setDevice(buf); -} - -/*! - Returns true if this packet is empty - that is, contains no data. - */ -bool QPacket::isEmpty() const -{ - return b.isEmpty(); -} - -/*! - Returns raw packet data. - */ -QByteArray QPacket::data() const -{ - return b; -} - -/*! - Clears data in the packet. This is useful for reusing one writable packet. - For example - \code - QPacketProtocol protocol(...); - - QPacket packet; - - packet << "Hello world!" << 123; - protocol.send(packet); - - packet.clear(); - packet << "Goodbyte world!" << 789; - protocol.send(packet); - \endcode - */ -void QPacket::clear() -{ - QBuffer::OpenMode oldMode = buf->openMode(); - buf->close(); - b.clear(); - buf->setBuffer(&b); // reset QBuffer internals with new size of b. - buf->open(oldMode); -} - -/*! - \class QPacketAutoSend - \internal - - \internal - */ -QPacketAutoSend::QPacketAutoSend(QPacketProtocol *_p) - : QPacket(), p(_p) -{ -} - -QPacketAutoSend::~QPacketAutoSend() -{ - if (!b.isEmpty()) - p->send(*this); -} - -QT_END_NAMESPACE - -#include <qpacketprotocol.moc> diff --git a/src/declarative/debugger/qpacketprotocol_p.h b/src/declarative/debugger/qpacketprotocol_p.h deleted file mode 100644 index eda7bfbac9..0000000000 --- a/src/declarative/debugger/qpacketprotocol_p.h +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 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> - -#include <private/qdeclarativeglobal_p.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QIODevice; -class QBuffer; -class QPacket; -class QPacketAutoSend; -class QPacketProtocolPrivate; - -class Q_DECLARATIVE_PRIVATE_EXPORT QPacketProtocol : public QObject -{ - Q_OBJECT -public: - explicit QPacketProtocol(QIODevice *dev, QObject *parent = 0); - virtual ~QPacketProtocol(); - - qint32 maximumPacketSize() const; - qint32 setMaximumPacketSize(qint32); - - QPacketAutoSend send(); - void send(const QPacket &); - - qint64 packetsAvailable() const; - QPacket read(); - - bool waitForReadyRead(int msecs = 3000); - - void clear(); - - QIODevice *device(); - -Q_SIGNALS: - void readyRead(); - void invalidPacket(); - void packetWritten(); - -private: - QPacketProtocolPrivate *d; -}; - - -class Q_DECLARATIVE_PRIVATE_EXPORT QPacket : public QDataStream -{ -public: - QPacket(); - QPacket(const QPacket &); - virtual ~QPacket(); - - void clear(); - bool isEmpty() const; - QByteArray data() const; - -protected: - friend class QPacketProtocol; - QPacket(const QByteArray &ba); - QByteArray b; - QBuffer *buf; -}; - -class Q_DECLARATIVE_PRIVATE_EXPORT QPacketAutoSend : public QPacket -{ -public: - virtual ~QPacketAutoSend(); - -private: - friend class QPacketProtocol; - QPacketAutoSend(QPacketProtocol *); - QPacketProtocol *p; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif diff --git a/src/declarative/debugger/qv8debugservice.cpp b/src/declarative/debugger/qv8debugservice.cpp deleted file mode 100644 index 389c465420..0000000000 --- a/src/declarative/debugger/qv8debugservice.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qv8debugservice_p.h" -#include "qdeclarativedebugservice_p_p.h" -#include <private/qjsconverter_impl_p.h> -#include <private/qv8engine_p.h> - -#include <QtCore/QHash> -#include <QtCore/QFileInfo> -#include <QtCore/QMutex> - -//V8 DEBUG SERVICE PROTOCOL -// <HEADER><COMMAND><DATA> -// <HEADER> : "V8DEBUG" -// <COMMAND> : ["connect", "disconnect", "interrupt", -// "v8request", "v8message", "breakonsignal", -// "breakaftercompile"] -// <DATA> : connect, disconnect, interrupt: empty -// v8request, v8message: <JSONrequest_string> -// breakonsignal: <signalname_string><enabled_bool> -// breakaftercompile: <enabled_bool> - -const char *V8_DEBUGGER_KEY_VERSION = "version"; -const char *V8_DEBUGGER_KEY_CONNECT = "connect"; -const char *V8_DEBUGGER_KEY_INTERRUPT = "interrupt"; -const char *V8_DEBUGGER_KEY_DISCONNECT = "disconnect"; -const char *V8_DEBUGGER_KEY_REQUEST = "v8request"; -const char *V8_DEBUGGER_KEY_V8MESSAGE = "v8message"; -const char *V8_DEBUGGER_KEY_BREAK_ON_SIGNAL = "breakonsignal"; -const char *V8_DEBUGGER_KEY_BREAK_AFTER_COMPILE = "breakaftercompile"; - -QT_BEGIN_NAMESPACE - -struct SignalHandlerData -{ - QString functionName; - bool enabled; -}; - -Q_GLOBAL_STATIC(QV8DebugService, v8ServiceInstance) - -// DebugMessageHandler will call back already when the QV8DebugService constructor is -// running, we therefore need a plain pointer. -static QV8DebugService *v8ServiceInstancePtr = 0; - -void DebugMessageDispatchHandler() -{ - QMetaObject::invokeMethod(v8ServiceInstancePtr, "processDebugMessages", Qt::QueuedConnection); -} - -void DebugMessageHandler(const v8::Debug::Message& message) -{ - v8::DebugEvent event = message.GetEvent(); - - if (event != v8::Break && event != v8::Exception && - event != v8::AfterCompile && event != v8::BeforeCompile) - return; - v8ServiceInstancePtr->debugMessageHandler(QJSConverter::toString(message.GetJSON()), event); -} - -class QV8DebugServicePrivate : public QDeclarativeDebugServicePrivate -{ -public: - QV8DebugServicePrivate() - : connectReceived(false) - , breakAfterCompile(false) - , engine(0) - { - } - - void initializeDebuggerThread(); - - static QByteArray packMessage(const QString &type, const QString &message = QString()); - - bool connectReceived; - bool breakAfterCompile; - QMutex initializeMutex; - QStringList breakOnSignals; - const QV8Engine *engine; -}; - -QV8DebugService::QV8DebugService(QObject *parent) - : QDeclarativeDebugService(*(new QV8DebugServicePrivate()), - QLatin1String("V8Debugger"), 2, parent) -{ - Q_D(QV8DebugService); - v8ServiceInstancePtr = this; - // wait for stateChanged() -> initialize() - d->initializeMutex.lock(); - if (registerService() == Enabled) { - init(); - // ,block mode, client attached - while (!d->connectReceived) { - waitForMessage(); - } - } else { - d->initializeMutex.unlock(); - } -} - -QV8DebugService::~QV8DebugService() -{ -} - -QV8DebugService *QV8DebugService::instance() -{ - return v8ServiceInstance(); -} - -void QV8DebugService::initialize(const QV8Engine *engine) -{ - // just make sure that the service is properly registered - v8ServiceInstance()->setEngine(engine); -} - -void QV8DebugService::setEngine(const QV8Engine *engine) -{ - Q_D(QV8DebugService); - - d->engine = engine; -} - -void QV8DebugService::debugMessageHandler(const QString &message, const v8::DebugEvent &event) -{ - Q_D(QV8DebugService); - sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_V8MESSAGE), message)); - if (event == v8::AfterCompile && d->breakAfterCompile) - scheduledDebugBreak(true); -} - -void QV8DebugService::signalEmitted(const QString &signal) -{ - //This function is only called by QDeclarativeBoundSignal - //only if there is a slot connected to the signal. Hence, there - //is no need for additional check. - Q_D(QV8DebugService); - - //Parse just the name and remove the class info - //Normalize to Lower case. - QString signalName = signal.left(signal.indexOf(QLatin1String("("))).toLower(); - - foreach (const QString &signal, d->breakOnSignals) { - if (signal == signalName) { - scheduledDebugBreak(true); - break; - } - } -} - -// executed in the gui thread -void QV8DebugService::init() -{ - Q_D(QV8DebugService); - v8::Debug::SetMessageHandler2(DebugMessageHandler); - v8::Debug::SetDebugMessageDispatchHandler(DebugMessageDispatchHandler); - d->initializeMutex.unlock(); -} - -// executed in the gui thread -void QV8DebugService::scheduledDebugBreak(bool schedule) -{ - if (schedule) - v8::Debug::DebugBreak(); - else - v8::Debug::CancelDebugBreak(); -} - -// executed in the debugger thread -void QV8DebugService::stateChanged(QDeclarativeDebugService::State newState) -{ - Q_D(QV8DebugService); - if (newState == Enabled) { - // execute in GUI thread - d->initializeMutex.lock(); - QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection); - } -} - -// executed in the debugger thread -void QV8DebugService::messageReceived(const QByteArray &message) -{ - Q_D(QV8DebugService); - - QDataStream ds(message); - QByteArray header; - ds >> header; - - if (header == "V8DEBUG") { - QByteArray command; - QByteArray data; - ds >> command >> data; - - if (command == V8_DEBUGGER_KEY_CONNECT) { - QMutexLocker locker(&d->initializeMutex); - d->connectReceived = true; - sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_CONNECT))); - - } else if (command == V8_DEBUGGER_KEY_INTERRUPT) { - // break has to be executed in gui thread - QMetaObject::invokeMethod(this, "scheduledDebugBreak", Qt::QueuedConnection, Q_ARG(bool, true)); - sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_INTERRUPT))); - - } else if (command == V8_DEBUGGER_KEY_DISCONNECT) { - // cancel break has to be executed in gui thread - QMetaObject::invokeMethod(this, "scheduledDebugBreak", Qt::QueuedConnection, Q_ARG(bool, false)); - sendDebugMessage(QString::fromUtf8(data)); - - } else if (command == V8_DEBUGGER_KEY_REQUEST) { - sendDebugMessage(QString::fromUtf8(data)); - - } else if (command == V8_DEBUGGER_KEY_BREAK_ON_SIGNAL) { - QDataStream rs(data); - QByteArray signal; - bool enabled; - rs >> signal >> enabled; - //Normalize to lower case. - QString signalName(QString::fromUtf8(signal).toLower()); - if (enabled) - d->breakOnSignals.append(signalName); - else - d->breakOnSignals.removeOne(signalName); - sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_BREAK_ON_SIGNAL))); - - } else if (command == V8_DEBUGGER_KEY_BREAK_AFTER_COMPILE) { - QDataStream rs(data); - rs >> d->breakAfterCompile; - sendMessage(QV8DebugServicePrivate::packMessage(QLatin1String(V8_DEBUGGER_KEY_BREAK_AFTER_COMPILE))); - - } - } -} - -void QV8DebugService::sendDebugMessage(const QString &message) -{ - v8::Debug::SendCommand(message.utf16(), message.size()); -} - -void QV8DebugService::processDebugMessages() -{ - Q_D(QV8DebugService); - v8::HandleScope handleScope; - v8::Context::Scope contextScope(d->engine->context()); - v8::Debug::ProcessDebugMessages(); -} - -QByteArray QV8DebugServicePrivate::packMessage(const QString &type, const QString &message) -{ - QByteArray reply; - QDataStream rs(&reply, QIODevice::WriteOnly); - QByteArray cmd("V8DEBUG"); - rs << cmd << type.toUtf8() << message.toUtf8(); - return reply; -} - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qv8debugservice_p.h b/src/declarative/debugger/qv8debugservice_p.h deleted file mode 100644 index 3f1d1ca177..0000000000 --- a/src/declarative/debugger/qv8debugservice_p.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QV8DEBUGSERVICE_P_H -#define QV8DEBUGSERVICE_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 "qdeclarativedebugservice_p.h" -#include <private/qv8debug_p.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QV8Engine; -class QV8DebugServicePrivate; - -class QV8DebugService : public QDeclarativeDebugService -{ - Q_OBJECT -public: - QV8DebugService(QObject *parent = 0); - ~QV8DebugService(); - - static QV8DebugService *instance(); - static void initialize(const QV8Engine *engine); - - void debugMessageHandler(const QString &message, const v8::DebugEvent &event); - - void signalEmitted(const QString &signal); - -public slots: - void processDebugMessages(); - -private slots: - void scheduledDebugBreak(bool schedule); - void sendDebugMessage(const QString &message); - void init(); - -protected: - void stateChanged(State newState); - void messageReceived(const QByteArray &); - -private: - void setEngine(const QV8Engine *engine); - -private: - Q_DISABLE_COPY(QV8DebugService) - Q_DECLARE_PRIVATE(QV8DebugService) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QV8DEBUGSERVICE_P_H diff --git a/src/declarative/debugger/qv8profilerservice.cpp b/src/declarative/debugger/qv8profilerservice.cpp deleted file mode 100644 index 5ae2d01cc2..0000000000 --- a/src/declarative/debugger/qv8profilerservice.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 "qv8profilerservice_p.h" -#include "qdeclarativedebugservice_p_p.h" -#include "private/qjsconverter_impl_p.h" -#include <private/qv8profiler_p.h> - -#include <QtCore/QHash> - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QV8ProfilerService, v8ProfilerInstance) - -class DebugServiceOutputStream : public v8::OutputStream -{ - QDeclarativeDebugService &_service; -public: - DebugServiceOutputStream(QDeclarativeDebugService &service) - : v8::OutputStream(), - _service(service) {} - void EndOfStream() {} - WriteResult WriteAsciiChunk(char *rawData, int size) - { - QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); - ds << QV8ProfilerService::V8SnapshotChunk << QByteArray(rawData, size); - _service.sendMessage(data); - return kContinue; - } -}; - -// convert to a QByteArray that can be sent to the debug client -QByteArray QV8ProfilerData::toByteArray() const -{ - QByteArray data; - //### using QDataStream is relatively expensive - QDataStream ds(&data, QIODevice::WriteOnly); - ds << messageType << filename << functionname << lineNumber << totalTime << selfTime << treeLevel; - - return data; -} - -class QV8ProfilerServicePrivate : public QDeclarativeDebugServicePrivate -{ - Q_DECLARE_PUBLIC(QV8ProfilerService) - -public: - QV8ProfilerServicePrivate() - :initialized(false) - { - } - - void takeSnapshot(v8::HeapSnapshot::Type); - - void printProfileTree(const v8::CpuProfileNode *node, int level = 0); - void sendMessages(); - - QList<QV8ProfilerData> m_data; - - bool initialized; - QList<QString> m_ongoing; -}; - -QV8ProfilerService::QV8ProfilerService(QObject *parent) - : QDeclarativeDebugService(*(new QV8ProfilerServicePrivate()), QLatin1String("V8Profiler"), 1, parent) -{ - Q_D(QV8ProfilerService); - - if (registerService() == Enabled) { - // ,block mode, client attached - while (!d->initialized) - waitForMessage(); - } -} - -QV8ProfilerService::~QV8ProfilerService() -{ -} - -QV8ProfilerService *QV8ProfilerService::instance() -{ - return v8ProfilerInstance(); -} - -void QV8ProfilerService::initialize() -{ - // just make sure that the service is properly registered - v8ProfilerInstance(); -} - -void QV8ProfilerService::stateAboutToBeChanged(QDeclarativeDebugService::State newState) -{ - Q_D(QV8ProfilerService); - - if (state() == newState) - return; - - if (state() == Enabled) { - foreach (const QString &title, d->m_ongoing) - QMetaObject::invokeMethod(this, "stopProfiling", Qt::QueuedConnection, Q_ARG(QString, title)); - sendProfilingData(); - } -} - -void QV8ProfilerService::messageReceived(const QByteArray &message) -{ - Q_D(QV8ProfilerService); - - QDataStream ds(message); - QByteArray command; - QByteArray option; - QByteArray title; - ds >> command >> option; - - if (command == "V8PROFILER") { - ds >> title; - QString titleStr = QString::fromUtf8(title); - if (option == "start") { - QMetaObject::invokeMethod(this, "startProfiling", Qt::QueuedConnection, Q_ARG(QString, titleStr)); - } else if (option == "stop" && d->initialized) { - QMetaObject::invokeMethod(this, "stopProfiling", Qt::QueuedConnection, Q_ARG(QString, titleStr)); - QMetaObject::invokeMethod(this, "sendProfilingData", Qt::QueuedConnection); - } - d->initialized = true; - } - - if (command == "V8SNAPSHOT") { - if (option == "full") - QMetaObject::invokeMethod(this, "takeSnapshot", Qt::QueuedConnection); - else if (option == "delete") { - QMetaObject::invokeMethod(this, "deleteSnapshots", Qt::QueuedConnection); - } - } - - QDeclarativeDebugService::messageReceived(message); -} - -void QV8ProfilerService::startProfiling(const QString &title) -{ - Q_D(QV8ProfilerService); - // Start Profiling - - if (d->m_ongoing.contains(title)) - return; - - v8::HandleScope handle_scope; - v8::Handle<v8::String> v8title = v8::String::New(reinterpret_cast<const uint16_t*>(title.data()), title.size()); - v8::CpuProfiler::StartProfiling(v8title); - - d->m_ongoing.append(title); -} - -void QV8ProfilerService::stopProfiling(const QString &title) -{ - Q_D(QV8ProfilerService); - // Stop profiling - - if (!d->m_ongoing.contains(title)) - return; - d->m_ongoing.removeOne(title); - - v8::HandleScope handle_scope; - v8::Handle<v8::String> v8title = v8::String::New(reinterpret_cast<const uint16_t*>(title.data()), title.size()); - const v8::CpuProfile *cpuProfile = v8::CpuProfiler::StopProfiling(v8title); - if (cpuProfile) { - // can happen at start - const v8::CpuProfileNode *rootNode = cpuProfile->GetTopDownRoot(); - d->printProfileTree(rootNode); - } -} - -void QV8ProfilerService::takeSnapshot() -{ - Q_D(QV8ProfilerService); - d->takeSnapshot(v8::HeapSnapshot::kFull); -} - -void QV8ProfilerService::deleteSnapshots() -{ - v8::HeapProfiler::DeleteAllSnapshots(); -} - -void QV8ProfilerService::sendProfilingData() -{ - Q_D(QV8ProfilerService); - // Send messages to client - d->sendMessages(); -} - -void QV8ProfilerServicePrivate::printProfileTree(const v8::CpuProfileNode *node, int level) -{ - for (int index = 0 ; index < node->GetChildrenCount() ; index++) { - const v8::CpuProfileNode* childNode = node->GetChild(index); - QString scriptResourceName = QJSConverter::toString(childNode->GetScriptResourceName()); - if (scriptResourceName.length() > 0) { - - QV8ProfilerData rd = {(int)QV8ProfilerService::V8Entry, scriptResourceName, - QJSConverter::toString(childNode->GetFunctionName()), - childNode->GetLineNumber(), childNode->GetTotalTime(), childNode->GetSelfTime(), level}; - m_data.append(rd); - - // different nodes might have common children: fix at client side - if (childNode->GetChildrenCount() > 0) { - printProfileTree(childNode, level+1); - } - } - } -} - -void QV8ProfilerServicePrivate::takeSnapshot(v8::HeapSnapshot::Type snapshotType) -{ - Q_Q(QV8ProfilerService); - - v8::HandleScope scope; - v8::Local<v8::String> title = v8::String::New(""); - - DebugServiceOutputStream outputStream(*q); - const v8::HeapSnapshot *snapshot = v8::HeapProfiler::TakeSnapshot(title, snapshotType); - snapshot->Serialize(&outputStream, v8::HeapSnapshot::kJSON); - - //indicate completion - QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); - ds << (int)QV8ProfilerService::V8SnapshotComplete; - - q->sendMessage(data); -} - -void QV8ProfilerServicePrivate::sendMessages() -{ - Q_Q(QV8ProfilerService); - - QList<QByteArray> messages; - for (int i = 0; i < m_data.count(); ++i) - messages << m_data.at(i).toByteArray(); - q->sendMessages(messages); - m_data.clear(); - - //indicate completion - QByteArray data; - QDataStream ds(&data, QIODevice::WriteOnly); - ds << (int)QV8ProfilerService::V8Complete; - - q->sendMessage(data); -} - - -QT_END_NAMESPACE diff --git a/src/declarative/debugger/qv8profilerservice_p.h b/src/declarative/debugger/qv8profilerservice_p.h deleted file mode 100644 index 706907ae23..0000000000 --- a/src/declarative/debugger/qv8profilerservice_p.h +++ /dev/null @@ -1,119 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** 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 QV8PROFILERSERVICE_P_H -#define QV8PROFILERSERVICE_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> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -struct Q_AUTOTEST_EXPORT QV8ProfilerData -{ - int messageType; - QString filename; - QString functionname; - int lineNumber; - double totalTime; - double selfTime; - int treeLevel; - - QByteArray toByteArray() const; -}; - -class QDeclarativeEngine; -class QV8ProfilerServicePrivate; - -class Q_AUTOTEST_EXPORT QV8ProfilerService : public QDeclarativeDebugService -{ - Q_OBJECT -public: - enum MessageType { - V8Entry, - V8Complete, - V8SnapshotChunk, - V8SnapshotComplete, - - V8MaximumMessage - }; - - QV8ProfilerService(QObject *parent = 0); - ~QV8ProfilerService(); - - static QV8ProfilerService *instance(); - static void initialize(); - -public slots: - void startProfiling(const QString &title); - void stopProfiling(const QString &title); - void takeSnapshot(); - void deleteSnapshots(); - - void sendProfilingData(); - -protected: - void stateAboutToBeChanged(State state); - void messageReceived(const QByteArray &); - -private: - Q_DISABLE_COPY(QV8ProfilerService) - Q_DECLARE_PRIVATE(QV8ProfilerService) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QV8PROFILERSERVICE_P_H |