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/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

View File

@@ -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

View File

@@ -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"));

View File

@@ -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);

View File

@@ -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;

View File

@@ -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();