aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmltooling/qmldbg_native
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_native')
-rw-r--r--src/plugins/qmltooling/qmldbg_native/qmldbg_native.pro9
-rw-r--r--src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp129
-rw-r--r--src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h89
3 files changed, 153 insertions, 74 deletions
diff --git a/src/plugins/qmltooling/qmldbg_native/qmldbg_native.pro b/src/plugins/qmltooling/qmldbg_native/qmldbg_native.pro
index 8902490aa0..e5489574be 100644
--- a/src/plugins/qmltooling/qmldbg_native/qmldbg_native.pro
+++ b/src/plugins/qmltooling/qmldbg_native/qmldbg_native.pro
@@ -1,9 +1,16 @@
TARGET = qmldbg_native
-QT = qml-private core-private
+QT = qml-private core-private packetprotocol-private
+
+HEADERS += \
+ $$PWD/../shared/qqmldebugpacket.h \
+ $$PWD/qqmlnativedebugconnector.h
SOURCES += \
$$PWD/qqmlnativedebugconnector.cpp
+INCLUDEPATH += $$PWD \
+ $$PWD/../shared
+
OTHER_FILES += \
$$PWD/qqmlnativedebugconnector.json
diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
index 6621eafb27..3145601612 100644
--- a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
+++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.cpp
@@ -1,41 +1,48 @@
/****************************************************************************
**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQml module of the Qt Toolkit.
**
-** $QT_BEGIN_LICENSE:LGPL21$
+** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company 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 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
-#include <private/qqmldebugconnector_p.h>
-#include <private/qhooks_p.h>
+#include "qqmlnativedebugconnector.h"
+#include "qqmldebugpacket.h"
-#include <qqmlengine.h>
+#include <private/qhooks_p.h>
+#include <QtQml/qjsengine.h>
#include <QtCore/qdebug.h>
#include <QtCore/qjsonarray.h>
#include <QtCore/qjsondocument.h>
@@ -65,7 +72,7 @@ Q_DECL_EXPORT void qt_qmlDebugConnectorOpen();
// member to some other place.
Q_DECL_EXPORT void qt_qmlDebugSetStreamVersion(int version)
{
- QQmlDebugStream::s_dataStreamVersion = version;
+ QQmlNativeDebugConnector::setDataStreamVersion(version);
}
@@ -172,55 +179,25 @@ Q_DECL_EXPORT void qt_qmlDebugConnectorOpen()
QT_BEGIN_NAMESPACE
-class QQmlNativeDebugConnector : public QQmlDebugConnector
-{
- Q_OBJECT
-
-public:
- QQmlNativeDebugConnector();
- ~QQmlNativeDebugConnector();
-
- bool blockingMode() const;
- QQmlDebugService *service(const QString &name) const;
- void addEngine(QQmlEngine *engine);
- void removeEngine(QQmlEngine *engine);
- bool addService(const QString &name, QQmlDebugService *service);
- bool removeService(const QString &name);
- bool open(const QVariantHash &configuration);
-
-private slots:
- void sendMessage(const QString &name, const QByteArray &message);
- void sendMessages(const QString &name, const QList<QByteArray> &messages);
-
-private:
- void announceObjectAvailability(const QString &objectType, QObject *object, bool available);
-
- QVector<QQmlDebugService *> m_services;
- bool m_blockingMode;
-};
-
QQmlNativeDebugConnector::QQmlNativeDebugConnector()
: m_blockingMode(false)
{
const QString args = commandLineArguments();
- const QStringList lstjsDebugArguments = args.split(QLatin1Char(','));
+ const auto lstjsDebugArguments = args.splitRef(QLatin1Char(','));
QStringList services;
- QStringList::const_iterator argsItEnd = lstjsDebugArguments.cend();
- QStringList::const_iterator argsIt = lstjsDebugArguments.cbegin();
- for (; argsIt != argsItEnd; ++argsIt) {
- const QString strArgument = *argsIt;
+ for (const QStringRef &strArgument : lstjsDebugArguments) {
if (strArgument == QLatin1String("block")) {
m_blockingMode = true;
} else if (strArgument == QLatin1String("native")) {
// Ignore. This is used to signal that this connector
// should be loaded and that has already happened.
} else if (strArgument.startsWith(QLatin1String("services:"))) {
- services.append(strArgument.mid(9));
+ services.append(strArgument.mid(9).toString());
} else if (!services.isEmpty()) {
- services.append(strArgument);
+ services.append(strArgument.toString());
} else {
qWarning("QML Debugger: Invalid argument \"%s\" detected. Ignoring the same.",
- qUtf8Printable(strArgument));
+ strArgument.toUtf8().constData());
}
}
setServices(services);
@@ -250,8 +227,10 @@ QQmlDebugService *QQmlNativeDebugConnector::service(const QString &name) const
return 0;
}
-void QQmlNativeDebugConnector::addEngine(QQmlEngine *engine)
+void QQmlNativeDebugConnector::addEngine(QJSEngine *engine)
{
+ Q_ASSERT(!m_engines.contains(engine));
+
TRACE_PROTOCOL("Add engine to connector:" << engine);
foreach (QQmlDebugService *service, m_services)
service->engineAboutToBeAdded(engine);
@@ -260,10 +239,14 @@ void QQmlNativeDebugConnector::addEngine(QQmlEngine *engine)
foreach (QQmlDebugService *service, m_services)
service->engineAdded(engine);
+
+ m_engines.append(engine);
}
-void QQmlNativeDebugConnector::removeEngine(QQmlEngine *engine)
+void QQmlNativeDebugConnector::removeEngine(QJSEngine *engine)
{
+ Q_ASSERT(m_engines.contains(engine));
+
TRACE_PROTOCOL("Remove engine from connector:" << engine);
foreach (QQmlDebugService *service, m_services)
service->engineAboutToBeRemoved(engine);
@@ -272,6 +255,13 @@ void QQmlNativeDebugConnector::removeEngine(QQmlEngine *engine)
foreach (QQmlDebugService *service, m_services)
service->engineRemoved(engine);
+
+ m_engines.removeOne(engine);
+}
+
+bool QQmlNativeDebugConnector::hasEngine(QJSEngine *engine) const
+{
+ return m_engines.contains(engine);
}
void QQmlNativeDebugConnector::announceObjectAvailability(const QString &objectType,
@@ -294,9 +284,8 @@ void QQmlNativeDebugConnector::announceObjectAvailability(const QString &objectT
bool QQmlNativeDebugConnector::addService(const QString &name, QQmlDebugService *service)
{
TRACE_PROTOCOL("Add service to connector: " << qPrintable(name) << service);
- for (QVector<QQmlDebugService *>::ConstIterator i = m_services.begin(); i != m_services.end();
- ++i) {
- if ((*i)->name() == name)
+ for (auto it = m_services.cbegin(), end = m_services.cend(); it != end; ++it) {
+ if ((*it)->name() == name)
return false;
}
@@ -338,6 +327,12 @@ bool QQmlNativeDebugConnector::open(const QVariantHash &configuration)
return true;
}
+void QQmlNativeDebugConnector::setDataStreamVersion(int version)
+{
+ Q_ASSERT(version <= QDataStream::Qt_DefaultCompiledVersion);
+ s_dataStreamVersion = version;
+}
+
void QQmlNativeDebugConnector::sendMessage(const QString &name, const QByteArray &message)
{
(*responseBuffer) += name.toUtf8() + ' ' + QByteArray::number(message.size()) + ' ' + message;
@@ -363,21 +358,9 @@ void QQmlNativeDebugConnector::sendMessages(const QString &name, const QList<QBy
sendMessage(name, messages.at(i));
}
-class QQmlNativeDebugConnectorFactory : public QQmlDebugConnectorFactory
+QQmlDebugConnector *QQmlNativeDebugConnectorFactory::create(const QString &key)
{
- Q_OBJECT
-
- Q_PLUGIN_METADATA(IID QQmlDebugConnectorFactory_iid FILE "qqmlnativedebugconnector.json")
-
-public:
- QQmlNativeDebugConnectorFactory() {}
-
- QQmlDebugConnector *create(const QString &key)
- {
- return key == QLatin1String("QQmlNativeDebugConnector") ? new QQmlNativeDebugConnector : 0;
- }
-};
+ return key == QLatin1String("QQmlNativeDebugConnector") ? new QQmlNativeDebugConnector : 0;
+}
QT_END_NAMESPACE
-
-#include "qqmlnativedebugconnector.moc"
diff --git a/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h
new file mode 100644
index 0000000000..03b5b5eb1e
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_native/qqmlnativedebugconnector.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQMLNATIVEDEBUGCONNECTOR_H
+#define QQMLNATIVEDEBUGCONNECTOR_H
+
+#include <private/qqmldebugconnector_p.h>
+#include <QtCore/qvector.h>
+
+QT_BEGIN_NAMESPACE
+
+class QQmlNativeDebugConnector : public QQmlDebugConnector
+{
+ Q_OBJECT
+
+public:
+ QQmlNativeDebugConnector();
+ ~QQmlNativeDebugConnector() Q_DECL_OVERRIDE;
+
+ bool blockingMode() const Q_DECL_OVERRIDE;
+ QQmlDebugService *service(const QString &name) const Q_DECL_OVERRIDE;
+ void addEngine(QJSEngine *engine) Q_DECL_OVERRIDE;
+ void removeEngine(QJSEngine *engine) Q_DECL_OVERRIDE;
+ bool hasEngine(QJSEngine *engine) const Q_DECL_OVERRIDE;
+ bool addService(const QString &name, QQmlDebugService *service) Q_DECL_OVERRIDE;
+ bool removeService(const QString &name) Q_DECL_OVERRIDE;
+ bool open(const QVariantHash &configuration) Q_DECL_OVERRIDE;
+ static void setDataStreamVersion(int version);
+
+private slots:
+ void sendMessage(const QString &name, const QByteArray &message);
+ void sendMessages(const QString &name, const QList<QByteArray> &messages);
+
+private:
+ void announceObjectAvailability(const QString &objectType, QObject *object, bool available);
+
+ QVector<QQmlDebugService *> m_services;
+ QVector<QJSEngine *> m_engines;
+ bool m_blockingMode;
+};
+
+class QQmlNativeDebugConnectorFactory : public QQmlDebugConnectorFactory
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QQmlDebugConnectorFactory_iid FILE "qqmlnativedebugconnector.json")
+public:
+ QQmlDebugConnector *create(const QString &key);
+};
+
+QT_END_NAMESPACE
+
+#endif // QQMLNATIVEDEBUGCONNECTOR_H
+