From 209c386e6026feac25c710baf0ad29b82ee5c5d2 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 22 Nov 2023 10:23:21 +0100 Subject: [PATCH] QmlProfiler: Dissolve plugin pimpl ... by using the new setup for QmlProfilerTool. Also, move the class definition to the .cpp. Change-Id: I3bc93f4960823914da9820fb2cb18de44f1c60c2 Reviewed-by: Jarek Kobus --- src/plugins/qmlprofiler/CMakeLists.txt | 2 +- src/plugins/qmlprofiler/qmlprofiler.qbs | 2 +- src/plugins/qmlprofiler/qmlprofilerplugin.cpp | 90 +++++++++---------- src/plugins/qmlprofiler/qmlprofilerplugin.h | 23 ----- src/plugins/qmlprofiler/qmlprofilertool.cpp | 19 ++-- src/plugins/qmlprofiler/qmlprofilertool.h | 3 + .../qmlprofiler/qmlprofilertraceview.cpp | 1 - 7 files changed, 62 insertions(+), 78 deletions(-) delete mode 100644 src/plugins/qmlprofiler/qmlprofilerplugin.h diff --git a/src/plugins/qmlprofiler/CMakeLists.txt b/src/plugins/qmlprofiler/CMakeLists.txt index a94dfce931a..9ef4fa63c56 100644 --- a/src/plugins/qmlprofiler/CMakeLists.txt +++ b/src/plugins/qmlprofiler/CMakeLists.txt @@ -49,7 +49,7 @@ set(QMLPROFILER_CPP_SOURCES qmlprofilereventtypes.h qmlprofilermodelmanager.cpp qmlprofilermodelmanager.h qmlprofilernotesmodel.cpp qmlprofilernotesmodel.h - qmlprofilerplugin.cpp qmlprofilerplugin.h + qmlprofilerplugin.cpp qmlprofilerrangemodel.cpp qmlprofilerrangemodel.h qmlprofilerrunconfigurationaspect.cpp qmlprofilerrunconfigurationaspect.h qmlprofilerruncontrol.cpp qmlprofilerruncontrol.h diff --git a/src/plugins/qmlprofiler/qmlprofiler.qbs b/src/plugins/qmlprofiler/qmlprofiler.qbs index 4ed25d1bca0..03bdd8fd8ed 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.qbs +++ b/src/plugins/qmlprofiler/qmlprofiler.qbs @@ -40,7 +40,7 @@ QtcPlugin { "qmlprofilereventtypes.h", "qmlprofilermodelmanager.cpp", "qmlprofilermodelmanager.h", "qmlprofilernotesmodel.cpp", "qmlprofilernotesmodel.h", - "qmlprofilerplugin.cpp", "qmlprofilerplugin.h", + "qmlprofilerplugin.cpp", "qmlprofilerrunconfigurationaspect.cpp", "qmlprofilerrunconfigurationaspect.h", "qmlprofilerrangemodel.cpp", "qmlprofilerrangemodel.h", "qmlprofilerruncontrol.cpp", "qmlprofilerruncontrol.h", diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp index e55ae38d764..17006579fa2 100644 --- a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp @@ -1,7 +1,6 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 -#include "qmlprofilerplugin.h" #include "qmlprofilerrunconfigurationaspect.h" #include "qmlprofilerruncontrol.h" #include "qmlprofilersettings.h" @@ -48,65 +47,64 @@ #include #include +#include + using namespace ProjectExplorer; namespace QmlProfiler::Internal { -class QmlProfilerPluginPrivate +class QmlProfilerPlugin final : public ExtensionSystem::IPlugin { -public: - QmlProfilerTool m_profilerTool; -}; + Q_OBJECT + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlProfiler.json") -bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString) -{ - Q_UNUSED(arguments) + bool initialize(const QStringList &arguments, QString *errorString) final + { + Q_UNUSED(arguments) - setupQmlProfilerRunning(); + setupQmlProfilerTool(); + setupQmlProfilerRunning(); #ifdef WITH_TESTS - addTest(); - addTest(); - addTest(); - addTest(); - addTest(); - addTest(); - addTest(); - addTest(); - addTest(); - addTest(); - addTest(); - addTest(); - addTest(); - addTest(); - addTest(); - addTest(); - addTest(); - addTest(); - addTest(); + addTest(); + addTest(); + addTest(); + addTest(); + addTest(); + addTest(); + addTest(); + addTest(); + addTest(); + addTest(); + addTest(); + addTest(); + addTest(); + addTest(); + addTest(); + addTest(); + addTest(); + addTest(); + addTest(); - addTest(); // Trigger debug connector to be started + addTest(); // Trigger debug connector to be started #endif - return Utils::HostOsInfo::canCreateOpenGLContext(errorString); -} + return Utils::HostOsInfo::canCreateOpenGLContext(errorString); + } -void QmlProfilerPlugin::extensionsInitialized() -{ - d = new QmlProfilerPluginPrivate; + void extensionsInitialized() final + { + RunConfiguration::registerAspect(); + } - RunConfiguration::registerAspect(); -} + ShutdownFlag aboutToShutdown() final + { + destroyQmlProfilerTool(); -ExtensionSystem::IPlugin::ShutdownFlag QmlProfilerPlugin::aboutToShutdown() -{ - delete d; - d = nullptr; - - // Save settings. - // Disconnect from signals that are not needed during shutdown - // Hide UI (if you add UI that is not in the main window directly) - return SynchronousShutdown; -} + return SynchronousShutdown; + } +}; } // QmlProfiler::Internal + +#include "qmlprofilerplugin.moc" diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.h b/src/plugins/qmlprofiler/qmlprofilerplugin.h deleted file mode 100644 index d04f016a877..00000000000 --- a/src/plugins/qmlprofiler/qmlprofilerplugin.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 - -#pragma once - -#include - -namespace QmlProfiler::Internal { - -class QmlProfilerPlugin : public ExtensionSystem::IPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlProfiler.json") - -private: - bool initialize(const QStringList &arguments, QString *errorString) final; - void extensionsInitialized() final; - ShutdownFlag aboutToShutdown() final; - - class QmlProfilerPluginPrivate *d = nullptr; -}; - -} // QmlProfiler::Internal diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index ea02239a64e..14369b6500d 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -7,7 +7,6 @@ #include "qmlprofilerclientmanager.h" #include "qmlprofilerconstants.h" #include "qmlprofilermodelmanager.h" -#include "qmlprofilerplugin.h" #include "qmlprofilerrunconfigurationaspect.h" #include "qmlprofilerruncontrol.h" #include "qmlprofilersettings.h" @@ -75,8 +74,7 @@ using namespace QmlProfiler::Constants; using namespace ProjectExplorer; using namespace Utils; -namespace QmlProfiler { -namespace Internal { +namespace QmlProfiler::Internal { static QmlProfilerTool *m_instance = nullptr; @@ -919,8 +917,17 @@ void QmlProfilerTool::toggleVisibleFeature(QAction *action) d->m_profilerModelManager->visibleFeatures() | (1ULL << feature)); else d->m_profilerModelManager->setVisibleFeatures( - d->m_profilerModelManager->visibleFeatures() & (~(1ULL << feature))); + d->m_profilerModelManager->visibleFeatures() & (~(1ULL << feature))); } -} // namespace Internal -} // namespace QmlProfiler +void setupQmlProfilerTool() +{ + (void) new QmlProfilerTool; +} + +void destroyQmlProfilerTool() +{ + delete m_instance; +} + +} // QmlProfiler::Internal diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h index 9db0691f1af..65bdc228c73 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.h +++ b/src/plugins/qmlprofiler/qmlprofilertool.h @@ -89,5 +89,8 @@ private: QmlProfilerToolPrivate *d; }; +void setupQmlProfilerTool(); +void destroyQmlProfilerTool(); + } // namespace Internal } // namespace QmlProfiler diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp index d07b731815a..290dc00dd81 100644 --- a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp @@ -4,7 +4,6 @@ #include "qmlprofileranimationsmodel.h" #include "qmlprofilermodelmanager.h" #include "qmlprofilernotesmodel.h" -#include "qmlprofilerplugin.h" #include "qmlprofilerrangemodel.h" #include "qmlprofilerstatemanager.h" #include "qmlprofilertool.h"