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>
This commit is contained in:
hjk
2018-02-15 14:40:18 +01:00
parent 8059bf6204
commit da33f94e20
6 changed files with 26 additions and 32 deletions

View File

@@ -71,8 +71,6 @@
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QtPlugin>
using namespace ProjectExplorer; using namespace ProjectExplorer;
namespace QmlProfiler { namespace QmlProfiler {
@@ -80,6 +78,13 @@ namespace Internal {
Q_GLOBAL_STATIC(QmlProfilerSettings, qmlProfilerGlobalSettings) Q_GLOBAL_STATIC(QmlProfilerSettings, qmlProfilerGlobalSettings)
class QmlProfilerPluginPrivate
{
public:
QmlProfilerTool m_profilerTool;
QmlProfilerOptionsPage m_profilerOptionsPage;
};
bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString) bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString)
{ {
Q_UNUSED(arguments) Q_UNUSED(arguments)
@@ -92,9 +97,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
void QmlProfilerPlugin::extensionsInitialized() void QmlProfilerPlugin::extensionsInitialized()
{ {
m_profilerTool = new QmlProfilerTool(this); d = new QmlProfilerPluginPrivate;
addAutoReleasedObject(new QmlProfilerOptionsPage);
RunConfiguration::registerAspect<QmlProfilerRunConfigurationAspect>(); RunConfiguration::registerAspect<QmlProfilerRunConfigurationAspect>();
@@ -109,20 +112,20 @@ void QmlProfilerPlugin::extensionsInitialized()
[this](RunControl *runControl) { [this](RunControl *runControl) {
QmlProfilerRunner *runner = new QmlProfilerRunner(runControl); QmlProfilerRunner *runner = new QmlProfilerRunner(runControl);
connect(runner, &QmlProfilerRunner::starting, connect(runner, &QmlProfilerRunner::starting,
m_profilerTool, &QmlProfilerTool::finalizeRunControl); &d->m_profilerTool, &QmlProfilerTool::finalizeRunControl);
return runner; return runner;
}); });
RunControl::registerWorker(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE, RunControl::registerWorker(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE,
[this](ProjectExplorer::RunControl *runControl) { [this](ProjectExplorer::RunControl *runControl) {
return new LocalQmlProfilerSupport(m_profilerTool, runControl); return new LocalQmlProfilerSupport(&d->m_profilerTool, runControl);
}, constraint); }, constraint);
} }
ExtensionSystem::IPlugin::ShutdownFlag QmlProfilerPlugin::aboutToShutdown() ExtensionSystem::IPlugin::ShutdownFlag QmlProfilerPlugin::aboutToShutdown()
{ {
delete m_profilerTool; delete d;
m_profilerTool = nullptr; d = nullptr;
// Save settings. // Save settings.
// Disconnect from signals that are not needed during shutdown // Disconnect from signals that are not needed during shutdown

View File

@@ -25,16 +25,12 @@
#pragma once #pragma once
#include "qmlprofiler_global.h"
#include "qmlprofilersettings.h"
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
#include "qmlprofilertimelinemodel.h"
namespace QmlProfiler { namespace QmlProfiler {
namespace Internal { namespace Internal {
class QmlProfilerTool; class QmlProfilerSettings;
class QmlProfilerPlugin : public ExtensionSystem::IPlugin 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") Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlProfiler.json")
public: public:
bool initialize(const QStringList &arguments, QString *errorString) override;
void extensionsInitialized() override;
ShutdownFlag aboutToShutdown() override;
static QmlProfilerSettings *globalSettings(); static QmlProfilerSettings *globalSettings();
QList<QObject *> createTestObjects() const override;
private: 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 } // namespace Internal

View File

@@ -131,8 +131,8 @@ public:
bool m_toolBusy = false; bool m_toolBusy = false;
}; };
QmlProfilerTool::QmlProfilerTool(QObject *parent) QmlProfilerTool::QmlProfilerTool()
: QObject(parent), d(new QmlProfilerToolPrivate) : d(new QmlProfilerToolPrivate)
{ {
setObjectName(QLatin1String("QmlProfilerTool")); setObjectName(QLatin1String("QmlProfilerTool"));

View File

@@ -32,11 +32,7 @@
#include <QAction> #include <QAction>
#include <QObject> #include <QObject>
namespace ProjectExplorer { namespace ProjectExplorer { class RunControl; }
class RunControl;
}
namespace QmlProfiler { namespace QmlProfiler {
@@ -53,7 +49,7 @@ class QMLPROFILER_EXPORT QmlProfilerTool : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit QmlProfilerTool(QObject *parent); QmlProfilerTool();
~QmlProfilerTool(); ~QmlProfilerTool();
void finalizeRunControl(QmlProfilerRunner *runWorker); void finalizeRunControl(QmlProfilerRunner *runWorker);

View File

@@ -44,7 +44,7 @@ LocalQmlProfilerRunnerTest::LocalQmlProfilerRunnerTest(QObject *parent) : QObjec
void LocalQmlProfilerRunnerTest::testRunner() void LocalQmlProfilerRunnerTest::testRunner()
{ {
QmlProfilerTool tool(nullptr); QmlProfilerTool tool;
QPointer<ProjectExplorer::RunControl> runControl; QPointer<ProjectExplorer::RunControl> runControl;
QPointer<LocalQmlProfilerSupport> profiler; QPointer<LocalQmlProfilerSupport> profiler;
ProjectExplorer::StandardRunnable debuggee; ProjectExplorer::StandardRunnable debuggee;

View File

@@ -41,7 +41,7 @@ namespace Internal {
void QmlProfilerToolTest::testAttachToWaitingApplication() void QmlProfilerToolTest::testAttachToWaitingApplication()
{ {
QmlProfilerTool profilerTool(nullptr); QmlProfilerTool profilerTool;
QTcpServer server; QTcpServer server;
QUrl serverUrl = Utils::urlFromLocalHostAndFreePort(); QUrl serverUrl = Utils::urlFromLocalHostAndFreePort();
QVERIFY(serverUrl.port() >= 0); QVERIFY(serverUrl.port() >= 0);
@@ -79,7 +79,7 @@ void QmlProfilerToolTest::testAttachToWaitingApplication()
void QmlProfilerToolTest::testClearEvents() void QmlProfilerToolTest::testClearEvents()
{ {
QmlProfilerTool profilerTool(nullptr); QmlProfilerTool profilerTool;
QmlProfilerModelManager *modelManager = profilerTool.modelManager(); QmlProfilerModelManager *modelManager = profilerTool.modelManager();
QVERIFY(modelManager); QVERIFY(modelManager);
QmlProfilerStateManager *stateManager = profilerTool.stateManager(); QmlProfilerStateManager *stateManager = profilerTool.stateManager();