diff options
author | hjk <hjk@qt.io> | 2019-03-13 13:07:09 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2019-03-13 16:02:48 +0000 |
commit | d0c052d23ae6f9fe14823668db93048b29fb6795 (patch) | |
tree | cbcdbada16d3486594421f679857123110cb448b /src/plugins/perfprofiler | |
parent | 164ae1428ed450703dbc89e367bbc2afa91476cf (diff) |
PerfProfiler: Move towards the canonical plugin setup pattern
Change-Id: I5d2f468c35c154664550175aefd21307b8107bba
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/perfprofiler')
-rw-r--r-- | src/plugins/perfprofiler/perfoptionspage.cpp | 2 | ||||
-rw-r--r-- | src/plugins/perfprofiler/perfoptionspage.h | 2 | ||||
-rw-r--r-- | src/plugins/perfprofiler/perfprofilerplugin.cpp | 45 | ||||
-rw-r--r-- | src/plugins/perfprofiler/perfprofilerplugin.h | 6 | ||||
-rw-r--r-- | src/plugins/perfprofiler/perfprofilertool.cpp | 3 | ||||
-rw-r--r-- | src/plugins/perfprofiler/perfprofilertool.h | 2 | ||||
-rw-r--r-- | src/plugins/perfprofiler/perfrunconfigurationaspect.cpp | 2 |
7 files changed, 40 insertions, 22 deletions
diff --git a/src/plugins/perfprofiler/perfoptionspage.cpp b/src/plugins/perfprofiler/perfoptionspage.cpp index 8b66475f770..356b073dd68 100644 --- a/src/plugins/perfprofiler/perfoptionspage.cpp +++ b/src/plugins/perfprofiler/perfoptionspage.cpp @@ -33,7 +33,7 @@ namespace PerfProfiler { namespace Internal { -PerfOptionsPage::PerfOptionsPage(QObject *parent) : Core::IOptionsPage(parent) +PerfOptionsPage::PerfOptionsPage() { setId(Constants::PerfSettingsId); setDisplayName(QCoreApplication::translate("PerfProfiler::PerfOptionsPage", "CPU Usage")); diff --git a/src/plugins/perfprofiler/perfoptionspage.h b/src/plugins/perfprofiler/perfoptionspage.h index 7f5da499e8b..febde556e0b 100644 --- a/src/plugins/perfprofiler/perfoptionspage.h +++ b/src/plugins/perfprofiler/perfoptionspage.h @@ -36,7 +36,7 @@ class PerfOptionsPage : public Core::IOptionsPage { Q_OBJECT public: - PerfOptionsPage(QObject *parent = nullptr); + PerfOptionsPage(); QWidget *widget(); void apply(); diff --git a/src/plugins/perfprofiler/perfprofilerplugin.cpp b/src/plugins/perfprofiler/perfprofilerplugin.cpp index a6fc393cabe..087fd0d7651 100644 --- a/src/plugins/perfprofiler/perfprofilerplugin.cpp +++ b/src/plugins/perfprofiler/perfprofilerplugin.cpp @@ -52,32 +52,44 @@ #include <QAction> #include <QDebug> #include <QMenu> -#include <QtPlugin> using namespace ProjectExplorer; namespace PerfProfiler { +namespace Internal { Q_GLOBAL_STATIC(PerfSettings, perfGlobalSettings) -bool PerfProfilerPlugin::initialize(const QStringList &arguments, QString *errorString) +class PerfProfilerPluginPrivate { - Q_UNUSED(arguments) - Q_UNUSED(errorString) +public: + PerfProfilerPluginPrivate() + { + RunConfiguration::registerAspect<PerfRunConfigurationAspect>(); - (void) new Internal::PerfOptionsPage(this); + RunControl::registerWorkerCreator(ProjectExplorer::Constants::PERFPROFILER_RUN_MODE, + [](RunControl *runControl){ return new PerfProfilerRunner(runControl); }); - RunConfiguration::registerAspect<PerfRunConfigurationAspect>(); + auto constraint = [](RunConfiguration *) { return true; }; + RunControl::registerWorker<PerfProfilerRunner> + (ProjectExplorer::Constants::PERFPROFILER_RUN_MODE, constraint); + } - (void) new Internal::PerfProfilerTool(this); + PerfOptionsPage optionsPage; + PerfProfilerTool profilerTool; +}; - RunControl::registerWorkerCreator(ProjectExplorer::Constants::PERFPROFILER_RUN_MODE, - [](RunControl *runControl){ return new Internal::PerfProfilerRunner(runControl); }); +PerfProfilerPlugin::~PerfProfilerPlugin() +{ + delete d; +} - auto constraint = [](RunConfiguration *) { return true; }; - RunControl::registerWorker<Internal::PerfProfilerRunner> - (ProjectExplorer::Constants::PERFPROFILER_RUN_MODE, constraint); +bool PerfProfilerPlugin::initialize(const QStringList &arguments, QString *errorString) +{ + Q_UNUSED(arguments) + Q_UNUSED(errorString) + d = new PerfProfilerPluginPrivate; return true; } @@ -85,19 +97,20 @@ void PerfProfilerPlugin::extensionsInitialized() { } -PerfProfiler::PerfSettings *PerfProfilerPlugin::globalSettings() +PerfSettings *PerfProfilerPlugin::globalSettings() { return perfGlobalSettings(); } -QList<QObject *> PerfProfiler::PerfProfilerPlugin::createTestObjects() const +QList<QObject *> PerfProfilerPlugin::createTestObjects() const { QList<QObject *> tests; #if WITH_TESTS - tests << new Internal::PerfProfilerTraceFileTest; - tests << new Internal::PerfResourceCounterTest; + tests << new PerfProfilerTraceFileTest; + tests << new PerfResourceCounterTest; #endif // WITH_TESTS return tests; } +} // namespace Internal } // namespace PerfProfiler diff --git a/src/plugins/perfprofiler/perfprofilerplugin.h b/src/plugins/perfprofiler/perfprofilerplugin.h index 35d79b099ff..9b80da48b8b 100644 --- a/src/plugins/perfprofiler/perfprofilerplugin.h +++ b/src/plugins/perfprofiler/perfprofilerplugin.h @@ -30,6 +30,7 @@ #include <extensionsystem/iplugin.h> namespace PerfProfiler { +namespace Internal { class PerfProfilerPlugin : public ExtensionSystem::IPlugin { @@ -37,11 +38,16 @@ class PerfProfilerPlugin : public ExtensionSystem::IPlugin Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "PerfProfiler.json") public: + ~PerfProfilerPlugin(); + bool initialize(const QStringList &arguments, QString *errorString) final; void extensionsInitialized() final; QList<QObject *> createTestObjects() const final; static PerfSettings *globalSettings(); + + class PerfProfilerPluginPrivate *d = nullptr; }; +} // namespace Internal } // namespace PerfProfiler diff --git a/src/plugins/perfprofiler/perfprofilertool.cpp b/src/plugins/perfprofiler/perfprofilertool.cpp index 5a25c32e9f6..b7a67d832c2 100644 --- a/src/plugins/perfprofiler/perfprofilertool.cpp +++ b/src/plugins/perfprofiler/perfprofilertool.cpp @@ -69,8 +69,7 @@ namespace Internal { static PerfProfilerTool *s_instance; -PerfProfilerTool::PerfProfilerTool(QObject *parent) : - QObject(parent) +PerfProfilerTool::PerfProfilerTool() { s_instance = this; m_traceManager = new PerfProfilerTraceManager(this); diff --git a/src/plugins/perfprofiler/perfprofilertool.h b/src/plugins/perfprofiler/perfprofilertool.h index 7c0296b28dd..03a31dc9013 100644 --- a/src/plugins/perfprofiler/perfprofilertool.h +++ b/src/plugins/perfprofiler/perfprofilertool.h @@ -48,7 +48,7 @@ class PerfProfilerTool : public QObject { Q_OBJECT public: - PerfProfilerTool(QObject *parent = nullptr); + PerfProfilerTool(); static PerfProfilerTool *instance(); PerfProfilerTraceManager *traceManager() const; diff --git a/src/plugins/perfprofiler/perfrunconfigurationaspect.cpp b/src/plugins/perfprofiler/perfrunconfigurationaspect.cpp index 498fd61b7b2..03509751f10 100644 --- a/src/plugins/perfprofiler/perfrunconfigurationaspect.cpp +++ b/src/plugins/perfprofiler/perfrunconfigurationaspect.cpp @@ -35,7 +35,7 @@ namespace PerfProfiler { PerfRunConfigurationAspect::PerfRunConfigurationAspect(ProjectExplorer::Target *target) { setProjectSettings(new PerfSettings(target)); - setGlobalSettings(PerfProfilerPlugin::globalSettings()); + setGlobalSettings(Internal::PerfProfilerPlugin::globalSettings()); setId(Constants::PerfSettingsId); setDisplayName(QCoreApplication::translate("PerfProfiler::PerfRunConfigurationAspect", "Performance Analyzer Settings")); |