diff options
Diffstat (limited to 'src/qml/debugger')
26 files changed, 620 insertions, 1110 deletions
diff --git a/src/qml/debugger/debugger.pri b/src/qml/debugger/debugger.pri deleted file mode 100644 index 202a46e550..0000000000 --- a/src/qml/debugger/debugger.pri +++ /dev/null @@ -1,30 +0,0 @@ -qtConfig(qml-debug) { - HEADERS += \ - $$PWD/qqmlabstractprofileradapter_p.h \ - $$PWD/qqmlconfigurabledebugservice_p.h \ - $$PWD/qqmldebugpluginmanager_p.h \ - $$PWD/qqmldebugservice_p.h \ - $$PWD/qqmldebugservicefactory_p.h \ - $$PWD/qqmldebugserver_p.h \ - $$PWD/qqmldebugserverconnection_p.h \ - $$PWD/qqmlprofilerdefinitions_p.h - - SOURCES += \ - $$PWD/qqmldebug.cpp \ - $$PWD/qqmldebugconnector.cpp \ - $$PWD/qqmldebugservice.cpp \ - $$PWD/qqmlabstractprofileradapter.cpp \ - $$PWD/qqmlmemoryprofiler.cpp \ - $$PWD/qqmlprofiler.cpp \ - $$PWD/qqmldebugserviceinterfaces.cpp -} - -HEADERS += \ - $$PWD/qqmldebugconnector_p.h \ - $$PWD/qqmldebugserviceinterfaces_p.h \ - $$PWD/qqmldebugstatesdelegate_p.h \ - $$PWD/qqmldebug.h \ - $$PWD/qqmlmemoryprofiler_p.h \ - $$PWD/qqmlprofiler_p.h - -INCLUDEPATH += $$PWD diff --git a/src/qml/debugger/qqmlabstractprofileradapter.cpp b/src/qml/debugger/qqmlabstractprofileradapter.cpp index 68b45ec6bf..94c71a94ad 100644 --- a/src/qml/debugger/qqmlabstractprofileradapter.cpp +++ b/src/qml/debugger/qqmlabstractprofileradapter.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qqmlabstractprofileradapter_p.h" diff --git a/src/qml/debugger/qqmlabstractprofileradapter_p.h b/src/qml/debugger/qqmlabstractprofileradapter_p.h index f39f8fccd2..c95eee949f 100644 --- a/src/qml/debugger/qqmlabstractprofileradapter_p.h +++ b/src/qml/debugger/qqmlabstractprofileradapter_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQMLABSTRACTPROFILERADAPTER_P_H #define QQMLABSTRACTPROFILERADAPTER_P_H @@ -62,7 +26,7 @@ QT_BEGIN_NAMESPACE QT_REQUIRE_CONFIG(qml_debug); class QQmlProfilerService; -class Q_QML_PRIVATE_EXPORT QQmlAbstractProfilerAdapter : public QObject, public QQmlProfilerDefinitions { +class Q_QML_EXPORT QQmlAbstractProfilerAdapter : public QObject, public QQmlProfilerDefinitions { Q_OBJECT public: @@ -79,7 +43,7 @@ public: void stopProfiling(); - void reportData() { emit dataRequested(); } + void reportData() { Q_EMIT dataRequested(); } void stopWaiting() { waiting = false; } void startWaiting() { waiting = true; } @@ -87,9 +51,9 @@ public: bool isRunning() const { return featuresEnabled != 0; } quint64 features() const { return featuresEnabled; } - void synchronize(const QElapsedTimer &t) { emit referenceTimeKnown(t); } + void synchronize(const QElapsedTimer &t) { Q_EMIT referenceTimeKnown(t); } -signals: +Q_SIGNALS: void profilingEnabled(quint64 features); void profilingEnabledWhileWaiting(quint64 features); @@ -107,7 +71,7 @@ private: quint64 featuresEnabled; }; -class Q_QML_PRIVATE_EXPORT QQmlAbstractProfilerAdapterFactory : public QObject +class Q_QML_EXPORT QQmlAbstractProfilerAdapterFactory : public QObject { Q_OBJECT public: diff --git a/src/qml/debugger/qqmlconfigurabledebugservice_p.h b/src/qml/debugger/qqmlconfigurabledebugservice_p.h index 96ec46f475..ce911c5baf 100644 --- a/src/qml/debugger/qqmlconfigurabledebugservice_p.h +++ b/src/qml/debugger/qqmlconfigurabledebugservice_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQMLCONFIGURABLEDEBUGSEVICE_P_H @@ -64,7 +28,7 @@ class QQmlConfigurableDebugService : public Base { protected: QQmlConfigurableDebugService(float version, QObject *parent = nullptr) : - Base(version, parent), m_configMutex(QMutex::Recursive) + Base(version, parent) { init(); } @@ -73,8 +37,8 @@ protected: { QMutexLocker lock(&m_configMutex); m_waitingForConfiguration = false; - for (QJSEngine *engine : qAsConst(m_waitingEngines)) - emit Base::attachedToEngine(engine); + for (QJSEngine *engine : std::as_const(m_waitingEngines)) + Q_EMIT Base::attachedToEngine(engine); m_waitingEngines.clear(); } @@ -100,10 +64,10 @@ protected: if (m_waitingForConfiguration) m_waitingEngines.append(engine); else - emit Base::attachedToEngine(engine); + Q_EMIT Base::attachedToEngine(engine); } - QMutex m_configMutex; + QRecursiveMutex m_configMutex; QList<QJSEngine *> m_waitingEngines; bool m_waitingForConfiguration; }; diff --git a/src/qml/debugger/qqmldebug.cpp b/src/qml/debugger/qqmldebug.cpp index 6532576e03..b9d984db1d 100644 --- a/src/qml/debugger/qqmldebug.cpp +++ b/src/qml/debugger/qqmldebug.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qqmldebug.h" #include "qqmldebugconnector_p.h" @@ -44,19 +8,35 @@ #include <private/qqmlengine_p.h> #include <private/qv4compileddata_p.h> +#include <atomic> #include <cstdio> QT_REQUIRE_CONFIG(qml_debug); QT_BEGIN_NAMESPACE -QQmlDebuggingEnabler::QQmlDebuggingEnabler(bool printWarning) +#if __cplusplus >= 202002L +# define Q_ATOMIC_FLAG_INIT {} +#else +# define Q_ATOMIC_FLAG_INIT ATOMIC_FLAG_INIT // deprecated in C++20 +#endif + +Q_CONSTINIT static std::atomic_flag s_printedWarning = Q_ATOMIC_FLAG_INIT; + +void QQmlDebuggingEnabler::enableDebugging(bool printWarning) { - if (!QQmlEnginePrivate::qml_debugging_enabled && printWarning) + if (printWarning && !s_printedWarning.test_and_set(std::memory_order_relaxed)) fprintf(stderr, "QML debugging is enabled. Only use this in a safe environment.\n"); - QQmlEnginePrivate::qml_debugging_enabled = true; + QQmlEnginePrivate::qml_debugging_enabled.store(true, std::memory_order_relaxed); } +#if QT_DEPRECATED_SINCE(6, 4) +QQmlDebuggingEnabler::QQmlDebuggingEnabler(bool printWarning) +{ + enableDebugging(printWarning); +}; +#endif // QT_DEPRECATED_SINCE(6, 4) + /*! * Retrieves the plugin keys of the debugger services provided by default. The debugger services * enable a debug client to use a Qml/JavaScript debugger, in order to set breakpoints, pause @@ -65,8 +45,7 @@ QQmlDebuggingEnabler::QQmlDebuggingEnabler(bool printWarning) */ QStringList QQmlDebuggingEnabler::debuggerServices() { - return QStringList() << QV4DebugService::s_key << QQmlEngineDebugService::s_key - << QDebugMessageService::s_key; + return {QV4DebugService::s_key, QQmlEngineDebugService::s_key, QDebugMessageService::s_key}; } /*! @@ -76,7 +55,7 @@ QStringList QQmlDebuggingEnabler::debuggerServices() */ QStringList QQmlDebuggingEnabler::inspectorServices() { - return QStringList() << QQmlInspectorService::s_key; + return {QQmlInspectorService::s_key}; } /*! @@ -87,8 +66,7 @@ QStringList QQmlDebuggingEnabler::inspectorServices() */ QStringList QQmlDebuggingEnabler::profilerServices() { - return QStringList() << QQmlProfilerService::s_key << QQmlEngineControlService::s_key - << QDebugMessageService::s_key; + return {QQmlProfilerService::s_key, QQmlEngineControlService::s_key, QDebugMessageService::s_key}; } /*! @@ -99,7 +77,7 @@ QStringList QQmlDebuggingEnabler::profilerServices() */ QStringList QQmlDebuggingEnabler::nativeDebuggerServices() { - return QStringList() << QQmlNativeDebugService::s_key; + return {QQmlNativeDebugService::s_key}; } /*! @@ -197,7 +175,7 @@ quintptr Q_QML_EXPORT qtDeclarativeHookData[] = { // TypeInformationVersion, an integral value, bumped whenever private // object sizes or member offsets that are used in Qt Creator's // data structure "pretty printing" change. - 3, + 4, // Version of the cache data. QV4_DATA_STRUCTURE_VERSION diff --git a/src/qml/debugger/qqmldebug.h b/src/qml/debugger/qqmldebug.h index d0ceb28cdc..6cc658a3e6 100644 --- a/src/qml/debugger/qqmldebug.h +++ b/src/qml/debugger/qqmldebug.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQMLDEBUG_H #define QQMLDEBUG_H @@ -43,6 +7,7 @@ #include <QtQml/qtqmlglobal.h> #include <QtCore/qstring.h> #include <QtCore/qvariant.h> +#include <QtCore/qhash.h> // QVariantHash QT_BEGIN_NAMESPACE @@ -55,7 +20,13 @@ struct Q_QML_EXPORT QQmlDebuggingEnabler WaitForClient }; + static void enableDebugging(bool printWarning); + +#if QT_DEPRECATED_SINCE(6, 4) + QT_DEPRECATED_VERSION_X_6_4("Use QQmlTriviallyDestructibleDebuggingEnabler instead " + "or just call QQmlDebuggingEnabler::enableDebugging().") QQmlDebuggingEnabler(bool printWarning = true); +#endif static QStringList debuggerServices(); static QStringList inspectorServices(); @@ -72,12 +43,23 @@ struct Q_QML_EXPORT QQmlDebuggingEnabler const QVariantHash &configuration = QVariantHash()); }; +// Unnamed namespace to signal the compiler that we +// indeed want each TU to have its own QQmlDebuggingEnabler. +namespace { +struct QQmlTriviallyDestructibleDebuggingEnabler { + QQmlTriviallyDestructibleDebuggingEnabler(bool printWarning = true) + { + static_assert(std::is_trivially_destructible_v<QQmlTriviallyDestructibleDebuggingEnabler>); + QQmlDebuggingEnabler::enableDebugging(printWarning); + } +}; // Execute code in constructor before first QQmlEngine is instantiated #if defined(QT_QML_DEBUG_NO_WARNING) -static QQmlDebuggingEnabler qQmlEnableDebuggingHelper(false); +static QQmlTriviallyDestructibleDebuggingEnabler qQmlEnableDebuggingHelper(false); #elif defined(QT_QML_DEBUG) -static QQmlDebuggingEnabler qQmlEnableDebuggingHelper(true); +static QQmlTriviallyDestructibleDebuggingEnabler qQmlEnableDebuggingHelper(true); #endif +} // unnamed namespace #endif diff --git a/src/qml/debugger/qqmldebugconnector.cpp b/src/qml/debugger/qqmldebugconnector.cpp index 0ef40d6911..0b66a29e18 100644 --- a/src/qml/debugger/qqmldebugconnector.cpp +++ b/src/qml/debugger/qqmldebugconnector.cpp @@ -1,50 +1,14 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qqmldebugpluginmanager_p.h" #include "qqmldebugconnector_p.h" #include "qqmldebugservicefactory_p.h" #include <QtCore/QPluginLoader> +#include <QtCore/QCborArray> #include <QtCore/QCoreApplication> #include <QtCore/QDir> #include <QtCore/QDebug> -#include <QtCore/QJsonArray> #include <QtCore/QDataStream> #include <private/qcoreapplication_p.h> @@ -111,7 +75,7 @@ QQmlDebugConnector *QQmlDebugConnector::instance() if (!params) return nullptr; - if (!QQmlEnginePrivate::qml_debugging_enabled) { + if (!QQmlEnginePrivate::qml_debugging_enabled.load(std::memory_order_relaxed)) { if (!params->arguments.isEmpty()) { qWarning().noquote() << QString::fromLatin1( "QML Debugger: Ignoring \"-qmljsdebugger=%1\". Debugging " @@ -131,7 +95,7 @@ QQmlDebugConnector *QQmlDebugConnector::instance() int connectorEnd = params->arguments.indexOf(QLatin1Char(','), connectorBegin); if (connectorEnd == -1) - connectorEnd = params->arguments.length(); + connectorEnd = params->arguments.size(); params->instance = loadQQmlDebugConnector(params->arguments.mid( connectorBegin, @@ -145,10 +109,10 @@ QQmlDebugConnector *QQmlDebugConnector::instance() if (params->instance) { const auto metaData = metaDataForQQmlDebugService(); - for (const QJsonObject &object : metaData) { - const auto keys = object.value(QLatin1String("MetaData")).toObject() + for (const QPluginParsedMetaData &md : metaData) { + const auto keys = md.value(QtPluginMetaDataKeys::MetaData).toMap() .value(QLatin1String("Keys")).toArray(); - for (const QJsonValue &key : keys) { + for (const QCborValue key : keys) { QString keyString = key.toString(); if (params->services.isEmpty() || params->services.contains(keyString)) loadQQmlDebugService(keyString); diff --git a/src/qml/debugger/qqmldebugconnector_p.h b/src/qml/debugger/qqmldebugconnector_p.h index d1ad90adfd..d021020bf4 100644 --- a/src/qml/debugger/qqmldebugconnector_p.h +++ b/src/qml/debugger/qqmldebugconnector_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQMLDEBUGCONNECTOR_H #define QQMLDEBUGCONNECTOR_H @@ -63,8 +27,9 @@ QT_BEGIN_NAMESPACE #if !QT_CONFIG(qml_debug) -class Q_QML_PRIVATE_EXPORT QQmlDebugConnector +class Q_QML_EXPORT QQmlDebugConnector { + virtual ~QQmlDebugConnector() = default; // don't break 'override' on ~QQmlDebugServer public: static QQmlDebugConnector *instance() { return nullptr; } @@ -85,7 +50,7 @@ public: #else class QQmlDebugService; -class Q_QML_PRIVATE_EXPORT QQmlDebugConnector : public QObject +class Q_QML_EXPORT QQmlDebugConnector : public QObject { Q_OBJECT public: @@ -122,7 +87,7 @@ protected: static int s_dataStreamVersion; }; -class Q_QML_PRIVATE_EXPORT QQmlDebugConnectorFactory : public QObject { +class Q_QML_EXPORT QQmlDebugConnectorFactory : public QObject { Q_OBJECT public: virtual QQmlDebugConnector *create(const QString &key) = 0; diff --git a/src/qml/debugger/qqmldebugpluginmanager_p.h b/src/qml/debugger/qqmldebugpluginmanager_p.h index 2575cbb96a..ffeeea17a8 100644 --- a/src/qml/debugger/qqmldebugpluginmanager_p.h +++ b/src/qml/debugger/qqmldebugpluginmanager_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQMLDEBUGPLUGINMANAGER_P_H #define QQMLDEBUGPLUGINMANAGER_P_H @@ -60,28 +24,27 @@ QT_BEGIN_NAMESPACE #if !QT_CONFIG(qml_debug) #define Q_QML_DEBUG_PLUGIN_LOADER(interfaceName)\ - interfaceName *load##interfaceName(const QString &key)\ + static interfaceName *load##interfaceName(const QString &key)\ {\ qWarning() << "Qml Debugger: QtQml is not configured for debugging. Ignoring request for"\ << "debug plugin" << key;\ return 0;\ }\ - QList<QJsonObject> metaDataFor##interfaceName()\ + Q_DECL_UNUSED static QList<QPluginParsedMetaData> metaDataFor##interfaceName()\ {\ - return QList<QJsonObject>();\ + return {};\ } -#define Q_QML_IMPORT_DEBUG_PLUGIN(className) #else // QT_CONFIG(qml_debug) #define Q_QML_DEBUG_PLUGIN_LOADER(interfaceName)\ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, interfaceName##Loader,\ (interfaceName##Factory_iid, QLatin1String("/qmltooling")))\ - interfaceName *load##interfaceName(const QString &key)\ + static interfaceName *load##interfaceName(const QString &key)\ {\ return qLoadPlugin<interfaceName, interfaceName##Factory>(interfaceName##Loader(), key);\ }\ - QList<QJsonObject> metaDataFor##interfaceName()\ + Q_DECL_UNUSED static QList<QPluginParsedMetaData> metaDataFor##interfaceName()\ {\ return interfaceName##Loader()->metaData();\ } diff --git a/src/qml/debugger/qqmldebugserver.cpp b/src/qml/debugger/qqmldebugserver.cpp new file mode 100644 index 0000000000..55a29ff1c5 --- /dev/null +++ b/src/qml/debugger/qqmldebugserver.cpp @@ -0,0 +1,13 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "qqmldebugserver_p.h" + +QT_BEGIN_NAMESPACE + +QQmlDebugServer::~QQmlDebugServer() + = default; + +QT_END_NAMESPACE + +#include "moc_qqmldebugserver_p.cpp" diff --git a/src/qml/debugger/qqmldebugserver_p.h b/src/qml/debugger/qqmldebugserver_p.h index e848b00bda..04e8b95f67 100644 --- a/src/qml/debugger/qqmldebugserver_p.h +++ b/src/qml/debugger/qqmldebugserver_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQMLDEBUGSERVER_P_H #define QQMLDEBUGSERVER_P_H @@ -58,10 +22,11 @@ QT_BEGIN_NAMESPACE -class Q_QML_PRIVATE_EXPORT QQmlDebugServer : public QQmlDebugConnector +class Q_QML_EXPORT QQmlDebugServer : public QQmlDebugConnector { Q_OBJECT public: + ~QQmlDebugServer() override; virtual void setDevice(QIODevice *socket) = 0; }; diff --git a/src/qml/debugger/qqmldebugserverconnection.cpp b/src/qml/debugger/qqmldebugserverconnection.cpp new file mode 100644 index 0000000000..8e23ee9be0 --- /dev/null +++ b/src/qml/debugger/qqmldebugserverconnection.cpp @@ -0,0 +1,16 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "qqmldebugserverconnection_p.h" + +QT_BEGIN_NAMESPACE + +QQmlDebugServerConnection::~QQmlDebugServerConnection() + = default; + +QQmlDebugServerConnectionFactory::~QQmlDebugServerConnectionFactory() + = default; + +QT_END_NAMESPACE + +#include "moc_qqmldebugserverconnection_p.cpp" diff --git a/src/qml/debugger/qqmldebugserverconnection_p.h b/src/qml/debugger/qqmldebugserverconnection_p.h index 9c4af4d225..c7ec68727c 100644 --- a/src/qml/debugger/qqmldebugserverconnection_p.h +++ b/src/qml/debugger/qqmldebugserverconnection_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQMLDEBUGSERVERCONNECTION_P_H #define QQMLDEBUGSERVERCONNECTION_P_H @@ -57,11 +21,12 @@ QT_BEGIN_NAMESPACE class QQmlDebugServer; -class Q_QML_PRIVATE_EXPORT QQmlDebugServerConnection : public QObject +class Q_QML_EXPORT QQmlDebugServerConnection : public QObject { Q_OBJECT public: QQmlDebugServerConnection(QObject *parent = nullptr) : QObject(parent) {} + ~QQmlDebugServerConnection() override; virtual void setServer(QQmlDebugServer *server) = 0; virtual bool setPortRange(int portFrom, int portTo, bool block, const QString &hostaddress) = 0; @@ -72,10 +37,11 @@ public: virtual void flush() = 0; }; -class Q_QML_PRIVATE_EXPORT QQmlDebugServerConnectionFactory : public QObject +class Q_QML_EXPORT QQmlDebugServerConnectionFactory : public QObject { Q_OBJECT public: + ~QQmlDebugServerConnectionFactory() override; virtual QQmlDebugServerConnection *create(const QString &key) = 0; }; diff --git a/src/qml/debugger/qqmldebugservice.cpp b/src/qml/debugger/qqmldebugservice.cpp index 4b77bee2c9..56cffc169c 100644 --- a/src/qml/debugger/qqmldebugservice.cpp +++ b/src/qml/debugger/qqmldebugservice.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qqmldebugservice_p.h" #include "qqmldebugconnector_p.h" @@ -139,8 +103,8 @@ Q_GLOBAL_STATIC(ObjectReferenceHash, objectReferenceHash) void ObjectReferenceHash::remove(QObject *obj) { - QHash<QObject *, int>::Iterator iter = objects.find(obj); - if (iter != objects.end()) { + const auto iter = objects.constFind(obj); + if (iter != objects.cend()) { ids.remove(iter.value()); objects.erase(iter); } @@ -156,9 +120,9 @@ int QQmlDebugService::idForObject(QObject *object) return -1; ObjectReferenceHash *hash = objectReferenceHash(); - QHash<QObject *, int>::Iterator iter = hash->objects.find(object); + auto iter = hash->objects.constFind(object); - if (iter == hash->objects.end()) { + if (iter == hash->objects.cend()) { int id = hash->nextId++; hash->ids.insert(id, object); iter = hash->objects.insert(object, id); diff --git a/src/qml/debugger/qqmldebugservice_p.h b/src/qml/debugger/qqmldebugservice_p.h index c52ba90a79..5970e89038 100644 --- a/src/qml/debugger/qqmldebugservice_p.h +++ b/src/qml/debugger/qqmldebugservice_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQMLDEBUGSERVICE_H #define QQMLDEBUGSERVICE_H @@ -63,7 +27,7 @@ QT_BEGIN_NAMESPACE class QJSEngine; class QQmlDebugServicePrivate; -class Q_QML_PRIVATE_EXPORT QQmlDebugService : public QObject +class Q_QML_EXPORT QQmlDebugService : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QQmlDebugService) @@ -82,8 +46,8 @@ public: virtual void stateChanged(State) {} virtual void messageReceived(const QByteArray &) {} - virtual void engineAboutToBeAdded(QJSEngine *engine) { emit attachedToEngine(engine); } - virtual void engineAboutToBeRemoved(QJSEngine *engine) { emit detachedFromEngine(engine); } + virtual void engineAboutToBeAdded(QJSEngine *engine) { Q_EMIT attachedToEngine(engine); } + virtual void engineAboutToBeRemoved(QJSEngine *engine) { Q_EMIT detachedFromEngine(engine); } virtual void engineAdded(QJSEngine *) {} virtual void engineRemoved(QJSEngine *) {} @@ -95,7 +59,7 @@ public: protected: explicit QQmlDebugService(const QString &, float version, QObject *parent = nullptr); -signals: +Q_SIGNALS: void attachedToEngine(QJSEngine *); void detachedFromEngine(QJSEngine *); diff --git a/src/qml/debugger/qqmldebugservicefactory.cpp b/src/qml/debugger/qqmldebugservicefactory.cpp new file mode 100644 index 0000000000..799052673d --- /dev/null +++ b/src/qml/debugger/qqmldebugservicefactory.cpp @@ -0,0 +1,13 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "qqmldebugservicefactory_p.h" + +QT_BEGIN_NAMESPACE + +QQmlDebugServiceFactory::~QQmlDebugServiceFactory() + = default; + +QT_END_NAMESPACE + +#include "moc_qqmldebugservicefactory_p.cpp" diff --git a/src/qml/debugger/qqmldebugservicefactory_p.h b/src/qml/debugger/qqmldebugservicefactory_p.h index 575a909f35..e9e4069efb 100644 --- a/src/qml/debugger/qqmldebugservicefactory_p.h +++ b/src/qml/debugger/qqmldebugservicefactory_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQMLDEBUGSERVICEFACTORY_P_H #define QQMLDEBUGSERVICEFACTORY_P_H @@ -55,10 +19,11 @@ QT_BEGIN_NAMESPACE -class Q_QML_PRIVATE_EXPORT QQmlDebugServiceFactory : public QObject +class Q_QML_EXPORT QQmlDebugServiceFactory : public QObject { Q_OBJECT public: + ~QQmlDebugServiceFactory() override; virtual QQmlDebugService *create(const QString &key) = 0; }; diff --git a/src/qml/debugger/qqmldebugserviceinterfaces.cpp b/src/qml/debugger/qqmldebugserviceinterfaces.cpp index 76205c7760..db1ec2db5e 100644 --- a/src/qml/debugger/qqmldebugserviceinterfaces.cpp +++ b/src/qml/debugger/qqmldebugserviceinterfaces.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qqmldebugserviceinterfaces_p.h" @@ -48,6 +12,84 @@ const QString QQmlProfilerService::s_key = QStringLiteral("CanvasFrameRate"); const QString QDebugMessageService::s_key = QStringLiteral("DebugMessages"); const QString QQmlEngineControlService::s_key = QStringLiteral("EngineControl"); const QString QQmlNativeDebugService::s_key = QStringLiteral("NativeQmlDebugger"); +#if QT_CONFIG(translation) +const QString QQmlDebugTranslationService::s_key = QStringLiteral("DebugTranslation"); +#endif + +QV4DebugService::~QV4DebugService() + = default; +QQmlEngineDebugService::~QQmlEngineDebugService() + = default; +QQmlInspectorService::~QQmlInspectorService() + = default; +QQmlProfilerService::~QQmlProfilerService() + = default; +QDebugMessageService::~QDebugMessageService() + = default; +QQmlEngineControlService::~QQmlEngineControlService() + = default; +QQmlNativeDebugService::~QQmlNativeDebugService() + = default; + +static QQmlDebugStatesDelegate *(*statesDelegateFactory)() = nullptr; +void QQmlEngineDebugService::setStatesDelegateFactory(QQmlDebugStatesDelegate *(*factory)()) +{ + statesDelegateFactory = factory; +} + +QQmlDebugStatesDelegate *QQmlEngineDebugService::createStatesDelegate() +{ + return statesDelegateFactory ? statesDelegateFactory() : nullptr; +} + +#if QT_CONFIG(translation) +QQmlDebugTranslationService::~QQmlDebugTranslationService() + = default; + +const TranslationBindingInformation TranslationBindingInformation::create( + const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, + const QV4::CompiledData::Binding *binding, QObject *scopeObject, + QQmlRefPointer<QQmlContextData> ctxt) +{ + QQmlTranslation translation; + if (binding->type() == QV4::CompiledData::Binding::Type_TranslationById) { + const QV4::CompiledData::TranslationData data = + compilationUnit->unitData()->translations()[binding->value.translationDataIndex]; + const QString id = compilationUnit->stringAt(data.stringIndex); + const int n = data.number; + + translation = QQmlTranslation(QQmlTranslation::QsTrIdData(id, n)); + } else { + Q_ASSERT(binding->type() == QV4::CompiledData::Binding::Type_Translation); + + const QV4::CompiledData::TranslationData data = + compilationUnit->unitData()->translations()[binding->value.translationDataIndex]; + const QString text = compilationUnit->stringAt(data.stringIndex); + const QString comment = compilationUnit->stringAt(data.commentIndex); + const bool hasContext + = data.contextIndex != QV4::CompiledData::TranslationData::NoContextIndex; + const int n = data.number; + + translation = QQmlTranslation( + QQmlTranslation::QsTrData( + hasContext + ? compilationUnit->stringAt(data.contextIndex) + : QQmlTranslation::contextFromQmlFilename( + compilationUnit->fileName()), + text, comment, n)); + } + + return { compilationUnit, + scopeObject, + ctxt, + + compilationUnit->stringAt(binding->propertyNameIndex), + translation, + + binding->location.line(), + binding->location.column() }; +} +#endif QT_END_NAMESPACE diff --git a/src/qml/debugger/qqmldebugserviceinterfaces_p.h b/src/qml/debugger/qqmldebugserviceinterfaces_p.h index 01693aee24..cd9022b497 100644 --- a/src/qml/debugger/qqmldebugserviceinterfaces_p.h +++ b/src/qml/debugger/qqmldebugserviceinterfaces_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQMLDEBUGSERVICEINTERFACES_P_H #define QQMLDEBUGSERVICEINTERFACES_P_H @@ -58,6 +22,7 @@ #endif #include <private/qqmldebugstatesdelegate_p.h> #include <private/qqmlboundsignal_p.h> +#include <private/qqmltranslation_p.h> #include <limits> @@ -66,8 +31,11 @@ QT_BEGIN_NAMESPACE class QWindow; class QQuickWindow; + #if !QT_CONFIG(qml_debug) +class TranslationBindingInformation; + class QV4DebugService { public: @@ -90,7 +58,7 @@ class QQmlEngineDebugService { public: void objectCreated(QJSEngine *, QObject *) {} - virtual void setStatesDelegate(QQmlDebugStatesDelegate *) {} + static void setStatesDelegateFactory(QQmlDebugStatesDelegate *(*)()) {} }; class QQmlInspectorService { @@ -103,13 +71,19 @@ public: class QDebugMessageService {}; class QQmlEngineControlService {}; class QQmlNativeDebugService {}; +class QQmlDebugTranslationService { +public: + virtual void foundTranslationBinding(const TranslationBindingInformation &) {} +}; #else -class Q_QML_PRIVATE_EXPORT QV4DebugService : public QQmlDebugService +class Q_QML_EXPORT QV4DebugService : public QQmlDebugService { Q_OBJECT public: + ~QV4DebugService() override; + static const QString s_key; virtual void signalEmitted(const QString &signal) = 0; @@ -117,15 +91,17 @@ public: protected: friend class QQmlDebugConnector; - QV4DebugService(float version, QObject *parent = nullptr) : + explicit QV4DebugService(float version, QObject *parent = nullptr) : QQmlDebugService(s_key, version, parent) {} }; class QQmlAbstractProfilerAdapter; -class Q_QML_PRIVATE_EXPORT QQmlProfilerService : public QQmlDebugService +class Q_QML_EXPORT QQmlProfilerService : public QQmlDebugService { Q_OBJECT public: + ~QQmlProfilerService() override; + static const QString s_key; virtual void addGlobalProfiler(QQmlAbstractProfilerAdapter *profiler) = 0; @@ -140,32 +116,74 @@ public: protected: friend class QQmlDebugConnector; - QQmlProfilerService(float version, QObject *parent = nullptr) : + explicit QQmlProfilerService(float version, QObject *parent = nullptr) : QQmlDebugService(s_key, version, parent) {} }; -class Q_QML_PRIVATE_EXPORT QQmlEngineDebugService : public QQmlDebugService +class Q_QML_EXPORT QQmlEngineDebugService : public QQmlDebugService { Q_OBJECT public: + ~QQmlEngineDebugService() override; + static const QString s_key; virtual void objectCreated(QJSEngine *engine, QObject *object) = 0; - virtual void setStatesDelegate(QQmlDebugStatesDelegate *) = 0; + static void setStatesDelegateFactory(QQmlDebugStatesDelegate *(*factory)()); + static QQmlDebugStatesDelegate *createStatesDelegate(); protected: friend class QQmlDebugConnector; - QQmlEngineDebugService(float version, QObject *parent = nullptr) : + explicit QQmlEngineDebugService(float version, QObject *parent = nullptr) : QQmlDebugService(s_key, version, parent) {} QQmlBoundSignal *nextSignal(QQmlBoundSignal *prev) { return prev->m_nextSignal; } }; -class Q_QML_PRIVATE_EXPORT QQmlInspectorService : public QQmlDebugService +#if QT_CONFIG(translation) +struct TranslationBindingInformation +{ + static const TranslationBindingInformation + create(const QQmlRefPointer<QV4::ExecutableCompilationUnit> &compilationUnit, + const QV4::CompiledData::Binding *binding, QObject *scopeObject, + QQmlRefPointer<QQmlContextData> ctxt); + + QQmlRefPointer<QV4::ExecutableCompilationUnit> compilationUnit; + QObject *scopeObject; + QQmlRefPointer<QQmlContextData> ctxt; + + QString propertyName; + QQmlTranslation translation; + + quint32 line; + quint32 column; +}; + +class Q_QML_EXPORT QQmlDebugTranslationService : public QQmlDebugService +{ + Q_OBJECT +public: + ~QQmlDebugTranslationService() override; + + static const QString s_key; + + virtual void foundTranslationBinding(const TranslationBindingInformation &translationBindingInformation) = 0; +protected: + friend class QQmlDebugConnector; + + explicit QQmlDebugTranslationService(float version, QObject *parent = nullptr) : + QQmlDebugService(s_key, version, parent) {} + +}; +#endif //QT_CONFIG(translation) + +class Q_QML_EXPORT QQmlInspectorService : public QQmlDebugService { Q_OBJECT public: + ~QQmlInspectorService() override; + static const QString s_key; virtual void addWindow(QQuickWindow *) = 0; @@ -175,14 +193,16 @@ public: protected: friend class QQmlDebugConnector; - QQmlInspectorService(float version, QObject *parent = nullptr) : + explicit QQmlInspectorService(float version, QObject *parent = nullptr) : QQmlDebugService(s_key, version, parent) {} }; -class Q_QML_PRIVATE_EXPORT QDebugMessageService : public QQmlDebugService +class Q_QML_EXPORT QDebugMessageService : public QQmlDebugService { Q_OBJECT public: + ~QDebugMessageService() override; + static const QString s_key; virtual void synchronizeTime(const QElapsedTimer &otherTimer) = 0; @@ -190,14 +210,16 @@ public: protected: friend class QQmlDebugConnector; - QDebugMessageService(float version, QObject *parent = nullptr) : + explicit QDebugMessageService(float version, QObject *parent = nullptr) : QQmlDebugService(s_key, version, parent) {} }; -class Q_QML_PRIVATE_EXPORT QQmlEngineControlService : public QQmlDebugService +class Q_QML_EXPORT QQmlEngineControlService : public QQmlDebugService { Q_OBJECT public: + ~QQmlEngineControlService() override; + static const QString s_key; protected: @@ -208,16 +230,18 @@ protected: }; -class Q_QML_PRIVATE_EXPORT QQmlNativeDebugService : public QQmlDebugService +class Q_QML_EXPORT QQmlNativeDebugService : public QQmlDebugService { Q_OBJECT public: + ~QQmlNativeDebugService() override; + static const QString s_key; protected: friend class QQmlDebugConnector; - QQmlNativeDebugService(float version, QObject *parent = nullptr) + explicit QQmlNativeDebugService(float version, QObject *parent = nullptr) : QQmlDebugService(s_key, version, parent) {} }; diff --git a/src/qml/debugger/qqmldebugstatesdelegate_p.h b/src/qml/debugger/qqmldebugstatesdelegate_p.h index b2e14873dc..b2b17070e7 100644 --- a/src/qml/debugger/qqmldebugstatesdelegate_p.h +++ b/src/qml/debugger/qqmldebugstatesdelegate_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQMLDEBUGSTATESDELEGATE_P_H #define QQMLDEBUGSTATESDELEGATE_P_H @@ -54,6 +18,7 @@ #include <QtQml/qtqmlglobal.h> #include <QtCore/QList> #include <QtCore/QPointer> +#include <QtCore/private/qglobal_p.h> QT_BEGIN_NAMESPACE diff --git a/src/qml/debugger/qqmldebugtranslationprotocol_p.h b/src/qml/debugger/qqmldebugtranslationprotocol_p.h new file mode 100644 index 0000000000..d4f5b8e1f4 --- /dev/null +++ b/src/qml/debugger/qqmldebugtranslationprotocol_p.h @@ -0,0 +1,265 @@ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#ifndef QQMLDEBUGTRANSLATIONPROTOCOL_P_H +#define QQMLDEBUGTRANSLATIONPROTOCOL_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/qdatastream.h> +#include <QtCore/qbuffer.h> +#include <QtCore/qurl.h> +#include <QtCore/qobjectdefs.h> +#include <QtCore/qmetaobject.h> +#include <QtCore/private/qglobal_p.h> +#include <tuple> + +QT_BEGIN_NAMESPACE + +namespace QQmlDebugTranslation { + +enum class Request { + ChangeLanguage = 1, + StateList, + ChangeState, + TranslationIssues, + TranslatableTextOccurrences, + WatchTextElides, + DisableWatchTextElides, + // following are obsolete, just provided for compilation compatibility + MissingTranslations +}; + +enum class Reply { + LanguageChanged = 101, + StateList, + StateChanged, + TranslationIssues, + TranslatableTextOccurrences, + // following are obsolete, just provided for compilation compatibility + MissingTranslations, + TextElided +}; + +inline QDataStream &operator<<(QDataStream &ds, Request r) +{ + return ds << int(r); +} + +inline QDataStream &operator>>(QDataStream &ds, Request &r) +{ + int i; + ds >> i; + r = Request(i); + return ds; +} + +inline QDataStream &operator<<(QDataStream &ds, Reply r) +{ + return ds << int(r); +} + +inline QDataStream &operator>>(QDataStream &ds, Reply &r) +{ + int i; + ds >> i; + r = Reply(i); + return ds; +} + +inline QByteArray createChangeLanguageRequest(QDataStream &packet, const QUrl &url, + const QString &locale) +{ + packet << Request::ChangeLanguage << url << locale; + return qobject_cast<QBuffer *>(packet.device())->data(); +} + +inline QByteArray createChangeStateRequest(QDataStream &packet, const QString &state) +{ + packet << Request::ChangeState << state; + return qobject_cast<QBuffer *>(packet.device())->data(); +} + +inline QByteArray createMissingTranslationsRequest(QDataStream &packet) +{ + packet << Request::MissingTranslations; + return qobject_cast<QBuffer *>(packet.device())->data(); +} + +inline QByteArray createTranslationIssuesRequest(QDataStream &packet) +{ + packet << Request::TranslationIssues; + return qobject_cast<QBuffer *>(packet.device())->data(); +} + +inline QByteArray createTranslatableTextOccurrencesRequest(QDataStream &packet) +{ + packet << Request::TranslatableTextOccurrences; + return qobject_cast<QBuffer *>(packet.device())->data(); +} + +inline QByteArray createStateListRequest(QDataStream &packet) +{ + packet << Request::StateList; + return qobject_cast<QBuffer *>(packet.device())->data(); +} + +inline QByteArray createWatchTextElidesRequest(QDataStream &packet) +{ + packet << Request::WatchTextElides; + return qobject_cast<QBuffer *>(packet.device())->data(); +} + +inline QByteArray createDisableWatchTextElidesRequest(QDataStream &packet) +{ + packet << Request::DisableWatchTextElides; + return qobject_cast<QBuffer *>(packet.device())->data(); +} + +class CodeMarker +{ +public: + friend QDataStream &operator>>(QDataStream &stream, CodeMarker &codeMarker) + { + return stream >> codeMarker.url + >> codeMarker.line + >> codeMarker.column; + } + + friend QDataStream &operator<<(QDataStream &stream, const CodeMarker &codeMarker) + { + return stream << codeMarker.url + << codeMarker.line + << codeMarker.column; + } + + friend bool operator<(const CodeMarker &first, const CodeMarker &second) + { + return std::tie(first.url, first.line, first.column) + < std::tie(second.url, second.line, second.column); + } + + friend bool operator==(const CodeMarker &first, const CodeMarker &second) + { + return first.line == second.line + && first.column == second.column + && first.url == second.url; + } + + QUrl url; + int line = -1; + int column = -1; +}; +class TranslationIssue +{ +public: + enum class Type{ + Missing, + Elided + }; + + friend QDataStream &operator>>(QDataStream &stream, TranslationIssue &issue) + { + int t; + stream >> issue.codeMarker + >> issue.language + >> t; + issue.type = Type(t); + return stream; + } + + friend QDataStream &operator<<(QDataStream &stream, const TranslationIssue &issue) + { + return stream << issue.codeMarker + << issue.language + << int(issue.type); + } + + friend bool operator==(const TranslationIssue &first, const TranslationIssue &second) + { + return first.type == second.type + && first.language == second.language + && first.codeMarker == second.codeMarker; + } + + QString toDebugString() const + { + QString debugString(QLatin1String( + "TranslationIssue(type=%1, line=%2, column=%3, url=%4, language=%5)")); + return debugString.arg(type == TranslationIssue::Type::Missing ? QLatin1String("Missing") + : QLatin1String("Elided"), + QString::number(codeMarker.line), QString::number(codeMarker.column), + codeMarker.url.toString(), language); + } + + QString language; + Type type = Type::Missing; + CodeMarker codeMarker; +}; +class QmlElement +{ +public: + QmlElement() = default; + + friend QDataStream &operator>>(QDataStream &stream, QmlElement &qmlElement) + { + return stream >> qmlElement.codeMarker >> qmlElement.elementId >> qmlElement.elementType + >> qmlElement.propertyName >> qmlElement.translationId >> qmlElement.translatedText + >> qmlElement.fontFamily >> qmlElement.fontPointSize >> qmlElement.fontPixelSize + >> qmlElement.fontStyleName >> qmlElement.horizontalAlignment + >> qmlElement.verticalAlignment >> qmlElement.stateName; + } + + friend QDataStream &operator<<(QDataStream &stream, const QmlElement &qmlElement) + { + return stream << qmlElement.codeMarker << qmlElement.elementId << qmlElement.elementType + << qmlElement.propertyName << qmlElement.translationId + << qmlElement.translatedText << qmlElement.fontFamily + << qmlElement.fontPointSize << qmlElement.fontPixelSize + << qmlElement.fontStyleName << qmlElement.horizontalAlignment + << qmlElement.verticalAlignment << qmlElement.stateName; + } + + CodeMarker codeMarker; + QString propertyName; + QString translationId; + QString translatedText; + QString fontFamily; + QString fontStyleName; + QString elementId; + QString elementType; + qreal fontPointSize = 0.0; + QString stateName; + int fontPixelSize = 0; + int horizontalAlignment = 0; + int verticalAlignment = 0; +}; + +class QmlState +{ +public: + QmlState() = default; + + friend QDataStream &operator>>(QDataStream &stream, QmlState &qmlState) + { + return stream >> qmlState.name; + } + + friend QDataStream &operator<<(QDataStream &stream, const QmlState &qmlState) + { + return stream << qmlState.name; + } + + QString name; +}; +} + +QT_END_NAMESPACE + +#endif // QQMLDEBUGTRANSLATIONPROTOCOL_P_H diff --git a/src/qml/debugger/qqmlmemoryprofiler.cpp b/src/qml/debugger/qqmlmemoryprofiler.cpp deleted file mode 100644 index b89dbfd02d..0000000000 --- a/src/qml/debugger/qqmlmemoryprofiler.cpp +++ /dev/null @@ -1,144 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include "qqmlmemoryprofiler_p.h" - -QT_BEGIN_NAMESPACE - - -QQmlMemoryScope::LibraryState QQmlMemoryScope::state = QQmlMemoryScope::Unloaded; - -typedef void (qmlmemprofile_stats)(int *allocCount, int *bytesAllocated); -typedef void (qmlmemprofile_clear)(); -typedef void (qmlmemprofile_enable)(); -typedef void (qmlmemprofile_disable)(); -typedef void (qmlmemprofile_push_location)(const char *filename, int lineNumber); -typedef void (qmlmemprofile_pop_location)(); -typedef void (qmlmemprofile_save)(const char *filename); -typedef int (qmlmemprofile_is_enabled)(); - -static qmlmemprofile_stats *memprofile_stats; -static qmlmemprofile_clear *memprofile_clear; -static qmlmemprofile_enable *memprofile_enable; -static qmlmemprofile_disable *memprofile_disable; -static qmlmemprofile_push_location *memprofile_push_location; -static qmlmemprofile_pop_location *memprofile_pop_location; -static qmlmemprofile_save *memprofile_save; -static qmlmemprofile_is_enabled *memprofile_is_enabled; - -#if QT_CONFIG(library) -extern QFunctionPointer qt_linux_find_symbol_sys(const char *symbol); -#endif - -bool QQmlMemoryScope::doOpenLibrary() -{ -#if defined(Q_OS_LINUX) && QT_CONFIG(library) - if (state == Unloaded) { - memprofile_stats = (qmlmemprofile_stats *) qt_linux_find_symbol_sys("qmlmemprofile_stats"); - memprofile_clear = (qmlmemprofile_clear *) qt_linux_find_symbol_sys("qmlmemprofile_clear"); - memprofile_enable = (qmlmemprofile_enable *) qt_linux_find_symbol_sys("qmlmemprofile_enable"); - memprofile_disable = (qmlmemprofile_disable *) qt_linux_find_symbol_sys("qmlmemprofile_disable"); - memprofile_push_location = (qmlmemprofile_push_location *) qt_linux_find_symbol_sys("qmlmemprofile_push_location"); - memprofile_pop_location = (qmlmemprofile_pop_location *) qt_linux_find_symbol_sys("qmlmemprofile_pop_location"); - memprofile_save = (qmlmemprofile_save *) qt_linux_find_symbol_sys("qmlmemprofile_save"); - memprofile_is_enabled = (qmlmemprofile_is_enabled *) qt_linux_find_symbol_sys("qmlmemprofile_is_enabled"); - - if (memprofile_stats && memprofile_clear && memprofile_enable && memprofile_disable && - memprofile_push_location && memprofile_pop_location && memprofile_save && memprofile_is_enabled) - state = Loaded; - else - state = Failed; - } -#endif // Q_OS_LINUX - - return state == Loaded; -} - -void QQmlMemoryScope::init(const char *string) -{ - if (memprofile_is_enabled()) { - memprofile_push_location(string, 0); - pushed = true; - } -} - -void QQmlMemoryScope::done() -{ - memprofile_pop_location(); -} - -bool QQmlMemoryProfiler::isEnabled() -{ - if (QQmlMemoryScope::openLibrary()) - return memprofile_is_enabled(); - - return false; -} - -void QQmlMemoryProfiler::enable() -{ - if (QQmlMemoryScope::openLibrary()) - memprofile_enable(); -} - -void QQmlMemoryProfiler::disable() -{ - if (QQmlMemoryScope::openLibrary()) - memprofile_disable(); -} - -void QQmlMemoryProfiler::clear() -{ - if (QQmlMemoryScope::openLibrary()) - memprofile_clear(); -} - -void QQmlMemoryProfiler::stats(int *allocCount, int *bytesAllocated) -{ - if (QQmlMemoryScope::openLibrary()) - memprofile_stats(allocCount, bytesAllocated); -} - -void QQmlMemoryProfiler::save(const char *filename) -{ - if (QQmlMemoryScope::openLibrary()) - memprofile_save(filename); -} - -QT_END_NAMESPACE diff --git a/src/qml/debugger/qqmlmemoryprofiler_p.h b/src/qml/debugger/qqmlmemoryprofiler_p.h deleted file mode 100644 index 12a31a851f..0000000000 --- a/src/qml/debugger/qqmlmemoryprofiler_p.h +++ /dev/null @@ -1,134 +0,0 @@ -/**************************************************************************** -** -** 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 QQMLMEMORYPROFILER_H -#define QQMLMEMORYPROFILER_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/qtqmlglobal_p.h> -#include <QUrl> - -QT_BEGIN_NAMESPACE - -#if !QT_CONFIG(qml_debug) - -#define QML_MEMORY_SCOPE_URL(url) -#define QML_MEMORY_SCOPE_STRING(s) - -#else - -class Q_QML_PRIVATE_EXPORT QQmlMemoryScope -{ -public: - explicit QQmlMemoryScope(const QUrl &url) - : pushed(false) - { - if (Q_UNLIKELY(openLibrary())) - init(url.path().toUtf8().constData()); - } - - explicit QQmlMemoryScope(const char *string) - : pushed(false) - { - if (Q_UNLIKELY(openLibrary())) - init(string); - } - - ~QQmlMemoryScope() - { - if (Q_UNLIKELY(pushed)) - done(); - } - - enum LibraryState - { - Unloaded, - Failed, - Loaded - }; - - static bool openLibrary() - { - if (Q_LIKELY(state == Loaded)) - return true; - if (state == Failed) - return false; - - return doOpenLibrary(); - } - -private: - Q_NEVER_INLINE void init(const char *string); - Q_NEVER_INLINE void done(); - Q_NEVER_INLINE static bool doOpenLibrary(); - - static LibraryState state; - - bool pushed; -}; - -class Q_QML_PRIVATE_EXPORT QQmlMemoryProfiler -{ -public: - static void enable(); - static void disable(); - static bool isEnabled(); - - static void clear(); - static void stats(int *allocCount, int *bytesAllocated); - static void save(const char *filename); -}; - -#define QML_MEMORY_SCOPE_URL(url) QQmlMemoryScope _qml_memory_scope(url) -#define QML_MEMORY_SCOPE_STRING(s) QQmlMemoryScope _qml_memory_scope(s) - -#endif - -QT_END_NAMESPACE -#endif // QQMLMEMORYPROFILER_H diff --git a/src/qml/debugger/qqmlprofiler.cpp b/src/qml/debugger/qqmlprofiler.cpp index da0b14dd85..281fdcda3c 100644 --- a/src/qml/debugger/qqmlprofiler.cpp +++ b/src/qml/debugger/qqmlprofiler.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qqmlprofiler_p.h" #include "qqmldebugservice_p.h" diff --git a/src/qml/debugger/qqmlprofiler_p.h b/src/qml/debugger/qqmlprofiler_p.h index d01e2bc429..2cf0e85760 100644 --- a/src/qml/debugger/qqmlprofiler_p.h +++ b/src/qml/debugger/qqmlprofiler_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQMLPROFILER_P_H #define QQMLPROFILER_P_H @@ -51,17 +15,18 @@ // We mean it. // -#include <private/qv4function_p.h> -#include <private/qqmlboundsignal_p.h> #include <private/qfinitestack_p.h> #include <private/qqmlbinding_p.h> +#include <private/qqmlboundsignal_p.h> +#include <private/qqmlglobal_p.h> +#include <private/qv4function_p.h> + #if QT_CONFIG(qml_debug) #include "qqmlprofilerdefinitions_p.h" -#include "qqmlabstractprofileradapter_p.h" #endif -#include <QUrl> -#include <QString> +#include <QtCore/qurl.h> +#include <QtCore/qstring.h> QT_BEGIN_NAMESPACE @@ -145,9 +110,9 @@ struct Q_AUTOTEST_EXPORT QQmlProfilerData : public QQmlProfilerDefinitions RangeType detailType; }; -Q_DECLARE_TYPEINFO(QQmlProfilerData, Q_MOVABLE_TYPE); +Q_DECLARE_TYPEINFO(QQmlProfilerData, Q_RELOCATABLE_TYPE); -class Q_QML_PRIVATE_EXPORT QQmlProfiler : public QObject, public QQmlProfilerDefinitions { +class Q_QML_EXPORT QQmlProfiler : public QObject, public QQmlProfilerDefinitions { Q_OBJECT public: @@ -171,11 +136,12 @@ public: : Location(ref->sourceLocation()), locationType(Binding), sent(false) { function = ref; - function->compilationUnit->addref(); + function->executableCompilationUnit()->addref(); } - RefLocation(QV4::CompiledData::CompilationUnit *ref, const QUrl &url, const QV4::CompiledData::Object *obj, const QString &type) - : Location(QQmlSourceLocation(type, obj->location.line, obj->location.column), url), + RefLocation(QV4::ExecutableCompilationUnit *ref, const QUrl &url, + const QV4::CompiledData::Object *obj, const QString &type) + : Location(QQmlSourceLocation(type, obj->location.line(), obj->location.column()), url), locationType(Creating), sent(false) { unit = ref; @@ -230,7 +196,7 @@ public: switch (locationType) { case Binding: - function->compilationUnit->addref(); + function->executableCompilationUnit()->addref(); break; case Creating: unit->addref(); @@ -254,7 +220,7 @@ public: switch (locationType) { case Binding: - function->compilationUnit->release(); + function->executableCompilationUnit()->release(); break; case Creating: unit->release(); @@ -284,7 +250,7 @@ public: RangeType locationType; union { QV4::Function *function; - QV4::CompiledData::CompilationUnit *unit; + QV4::ExecutableCompilationUnit *unit; QQmlBoundSignalExpression *boundSignal; QQmlDataBlob *blob; void *something; @@ -356,7 +322,7 @@ public: } void updateCreating(const QV4::CompiledData::Object *obj, - QV4::CompiledData::CompilationUnit *ref, + QV4::ExecutableCompilationUnit *ref, const QUrl &url, const QString &type) { quintptr locationId(id(obj)); @@ -386,7 +352,7 @@ public: void reportData(); void setTimer(const QElapsedTimer &timer) { m_timer = timer; } -signals: +Q_SIGNALS: void dataReady(const QVector<QQmlProfilerData> &, const QQmlProfiler::LocationHash &); protected: @@ -492,7 +458,7 @@ public: Q_QML_PROFILE(QQmlProfilerDefinitions::ProfileCreating, profiler, endRange<QQmlProfilerDefinitions::Creating>()); } - void update(QV4::CompiledData::CompilationUnit *ref, const QV4::CompiledData::Object *obj, + void update(QV4::ExecutableCompilationUnit *ref, const QV4::CompiledData::Object *obj, const QString &typeName, const QUrl &url) { profiler->updateCreating(obj, ref, url, typeName); diff --git a/src/qml/debugger/qqmlprofilerdefinitions_p.h b/src/qml/debugger/qqmlprofilerdefinitions_p.h index 7b972c5d0d..7e87e8ac13 100644 --- a/src/qml/debugger/qqmlprofilerdefinitions_p.h +++ b/src/qml/debugger/qqmlprofilerdefinitions_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QQMLPROFILERDEFINITIONS_P_H #define QQMLPROFILERDEFINITIONS_P_H @@ -70,6 +34,7 @@ struct QQmlProfilerDefinitions { SceneGraphFrame, MemoryAllocation, DebugMessage, + Quick3DFrame, MaximumMessage }; @@ -124,6 +89,22 @@ struct QQmlProfilerDefinitions { NumGUIThreadFrameTypes = MaximumSceneGraphFrameType - NumRenderThreadFrameTypes }; + enum Quick3DFrameType { + Quick3DRenderFrame, // Render Thread + Quick3DSynchronizeFrame, + Quick3DPrepareFrame, + Quick3DMeshLoad, + Quick3DCustomMeshLoad, + Quick3DTextureLoad, + Quick3DGenerateShader, + Quick3DLoadShader, + Quick3DParticleUpdate, // GUI Thread + Quick3DRenderCall, // Render Thread + Quick3DRenderPass, // Render Thread + Quick3DEventData, // N/A + MaximumQuick3DFrameType, + }; + enum ProfileFeature { ProfileJavaScript, ProfileMemory, @@ -137,6 +118,7 @@ struct QQmlProfilerDefinitions { ProfileHandlingSignal, ProfileInputEvents, ProfileDebugMessages, + ProfileQuick3D, MaximumProfileFeature }; |