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 #include #include -#include using namespace ProjectExplorer; namespace PerfProfiler { +namespace Internal { Q_GLOBAL_STATIC(PerfSettings, perfGlobalSettings) +class PerfProfilerPluginPrivate +{ +public: + PerfProfilerPluginPrivate() + { + RunConfiguration::registerAspect(); + + RunControl::registerWorkerCreator(ProjectExplorer::Constants::PERFPROFILER_RUN_MODE, + [](RunControl *runControl){ return new PerfProfilerRunner(runControl); }); + + auto constraint = [](RunConfiguration *) { return true; }; + RunControl::registerWorker + (ProjectExplorer::Constants::PERFPROFILER_RUN_MODE, constraint); + } + + PerfOptionsPage optionsPage; + PerfProfilerTool profilerTool; +}; + +PerfProfilerPlugin::~PerfProfilerPlugin() +{ + delete d; +} + bool PerfProfilerPlugin::initialize(const QStringList &arguments, QString *errorString) { Q_UNUSED(arguments) Q_UNUSED(errorString) - (void) new Internal::PerfOptionsPage(this); - - RunConfiguration::registerAspect(); - - (void) new Internal::PerfProfilerTool(this); - - RunControl::registerWorkerCreator(ProjectExplorer::Constants::PERFPROFILER_RUN_MODE, - [](RunControl *runControl){ return new Internal::PerfProfilerRunner(runControl); }); - - auto constraint = [](RunConfiguration *) { return true; }; - RunControl::registerWorker - (ProjectExplorer::Constants::PERFPROFILER_RUN_MODE, constraint); - + d = new PerfProfilerPluginPrivate; return true; } @@ -85,19 +97,20 @@ void PerfProfilerPlugin::extensionsInitialized() { } -PerfProfiler::PerfSettings *PerfProfilerPlugin::globalSettings() +PerfSettings *PerfProfilerPlugin::globalSettings() { return perfGlobalSettings(); } -QList PerfProfiler::PerfProfilerPlugin::createTestObjects() const +QList PerfProfilerPlugin::createTestObjects() const { QList 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 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 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"));