diff options
author | hjk <hjk@qt.io> | 2018-02-15 14:40:18 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2018-02-19 10:17:36 +0000 |
commit | da33f94e207ed8bd2a9e549a327ff00540bd3935 (patch) | |
tree | 6105c3da131f63c7033185ffb3ffd691212479f5 | |
parent | 8059bf62049d730fff13aa1764fe2df6f8cacf91 (diff) |
QmlProfiler: Pimpl QmlProfilerPlugin class a bit more
... to be able to remove an unneeded use of the global object pool.
Plus some code cosmetics.
Change-Id: Ifdb0ff9cd40820a34a8951563402a50a594e4fdd
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerplugin.cpp | 21 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilerplugin.h | 19 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilertool.cpp | 4 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/qmlprofilertool.h | 8 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp | 2 | ||||
-rw-r--r-- | src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp | 4 |
6 files changed, 26 insertions, 32 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp index 3f738a3fc5..453a4f7c6d 100644 --- a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp @@ -71,8 +71,6 @@ #include <utils/hostosinfo.h> #include <utils/qtcassert.h> -#include <QtPlugin> - using namespace ProjectExplorer; namespace QmlProfiler { @@ -80,6 +78,13 @@ namespace Internal { Q_GLOBAL_STATIC(QmlProfilerSettings, qmlProfilerGlobalSettings) +class QmlProfilerPluginPrivate +{ +public: + QmlProfilerTool m_profilerTool; + QmlProfilerOptionsPage m_profilerOptionsPage; +}; + bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString) { Q_UNUSED(arguments) @@ -92,9 +97,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS void QmlProfilerPlugin::extensionsInitialized() { - m_profilerTool = new QmlProfilerTool(this); - - addAutoReleasedObject(new QmlProfilerOptionsPage); + d = new QmlProfilerPluginPrivate; RunConfiguration::registerAspect<QmlProfilerRunConfigurationAspect>(); @@ -109,20 +112,20 @@ void QmlProfilerPlugin::extensionsInitialized() [this](RunControl *runControl) { QmlProfilerRunner *runner = new QmlProfilerRunner(runControl); connect(runner, &QmlProfilerRunner::starting, - m_profilerTool, &QmlProfilerTool::finalizeRunControl); + &d->m_profilerTool, &QmlProfilerTool::finalizeRunControl); return runner; }); RunControl::registerWorker(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE, [this](ProjectExplorer::RunControl *runControl) { - return new LocalQmlProfilerSupport(m_profilerTool, runControl); + return new LocalQmlProfilerSupport(&d->m_profilerTool, runControl); }, constraint); } ExtensionSystem::IPlugin::ShutdownFlag QmlProfilerPlugin::aboutToShutdown() { - delete m_profilerTool; - m_profilerTool = nullptr; + delete d; + d = nullptr; // Save settings. // Disconnect from signals that are not needed during shutdown diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.h b/src/plugins/qmlprofiler/qmlprofilerplugin.h index 88b764e95a..73383bb500 100644 --- a/src/plugins/qmlprofiler/qmlprofilerplugin.h +++ b/src/plugins/qmlprofiler/qmlprofilerplugin.h @@ -25,16 +25,12 @@ #pragma once -#include "qmlprofiler_global.h" -#include "qmlprofilersettings.h" #include <extensionsystem/iplugin.h> -#include "qmlprofilertimelinemodel.h" - namespace QmlProfiler { namespace Internal { -class QmlProfilerTool; +class QmlProfilerSettings; class QmlProfilerPlugin : public ExtensionSystem::IPlugin { @@ -42,16 +38,15 @@ class QmlProfilerPlugin : public ExtensionSystem::IPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlProfiler.json") public: - bool initialize(const QStringList &arguments, QString *errorString) override; - void extensionsInitialized() override; - ShutdownFlag aboutToShutdown() override; - static QmlProfilerSettings *globalSettings(); - QList<QObject *> createTestObjects() const override; - private: - QmlProfilerTool *m_profilerTool = nullptr; + bool initialize(const QStringList &arguments, QString *errorString) final; + void extensionsInitialized() final; + ShutdownFlag aboutToShutdown() final; + QList<QObject *> createTestObjects() const final; + + class QmlProfilerPluginPrivate *d = nullptr; }; } // namespace Internal diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index a3432c6c8a..adb166a7f1 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -131,8 +131,8 @@ public: bool m_toolBusy = false; }; -QmlProfilerTool::QmlProfilerTool(QObject *parent) - : QObject(parent), d(new QmlProfilerToolPrivate) +QmlProfilerTool::QmlProfilerTool() + : d(new QmlProfilerToolPrivate) { setObjectName(QLatin1String("QmlProfilerTool")); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h index 3211e1a8bf..3a60911ef0 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.h +++ b/src/plugins/qmlprofiler/qmlprofilertool.h @@ -32,11 +32,7 @@ #include <QAction> #include <QObject> -namespace ProjectExplorer { - -class RunControl; - -} +namespace ProjectExplorer { class RunControl; } namespace QmlProfiler { @@ -53,7 +49,7 @@ class QMLPROFILER_EXPORT QmlProfilerTool : public QObject Q_OBJECT public: - explicit QmlProfilerTool(QObject *parent); + QmlProfilerTool(); ~QmlProfilerTool(); void finalizeRunControl(QmlProfilerRunner *runWorker); diff --git a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp index 007dac486a..e4591ac30e 100644 --- a/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp +++ b/src/plugins/qmlprofiler/tests/localqmlprofilerrunner_test.cpp @@ -44,7 +44,7 @@ LocalQmlProfilerRunnerTest::LocalQmlProfilerRunnerTest(QObject *parent) : QObjec void LocalQmlProfilerRunnerTest::testRunner() { - QmlProfilerTool tool(nullptr); + QmlProfilerTool tool; QPointer<ProjectExplorer::RunControl> runControl; QPointer<LocalQmlProfilerSupport> profiler; ProjectExplorer::StandardRunnable debuggee; diff --git a/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp b/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp index e973e96780..5ed54ca4c4 100644 --- a/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp +++ b/src/plugins/qmlprofiler/tests/qmlprofilertool_test.cpp @@ -41,7 +41,7 @@ namespace Internal { void QmlProfilerToolTest::testAttachToWaitingApplication() { - QmlProfilerTool profilerTool(nullptr); + QmlProfilerTool profilerTool; QTcpServer server; QUrl serverUrl = Utils::urlFromLocalHostAndFreePort(); QVERIFY(serverUrl.port() >= 0); @@ -79,7 +79,7 @@ void QmlProfilerToolTest::testAttachToWaitingApplication() void QmlProfilerToolTest::testClearEvents() { - QmlProfilerTool profilerTool(nullptr); + QmlProfilerTool profilerTool; QmlProfilerModelManager *modelManager = profilerTool.modelManager(); QVERIFY(modelManager); QmlProfilerStateManager *stateManager = profilerTool.stateManager(); |