QmlProfiler: Dissolve plugin pimpl

... by using the new setup for QmlProfilerTool.

Also, move the class definition to the .cpp.

Change-Id: I3bc93f4960823914da9820fb2cb18de44f1c60c2
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2023-11-22 10:23:21 +01:00
parent db71c461de
commit 209c386e60
7 changed files with 62 additions and 78 deletions

View File

@@ -49,7 +49,7 @@ set(QMLPROFILER_CPP_SOURCES
qmlprofilereventtypes.h qmlprofilereventtypes.h
qmlprofilermodelmanager.cpp qmlprofilermodelmanager.h qmlprofilermodelmanager.cpp qmlprofilermodelmanager.h
qmlprofilernotesmodel.cpp qmlprofilernotesmodel.h qmlprofilernotesmodel.cpp qmlprofilernotesmodel.h
qmlprofilerplugin.cpp qmlprofilerplugin.h qmlprofilerplugin.cpp
qmlprofilerrangemodel.cpp qmlprofilerrangemodel.h qmlprofilerrangemodel.cpp qmlprofilerrangemodel.h
qmlprofilerrunconfigurationaspect.cpp qmlprofilerrunconfigurationaspect.h qmlprofilerrunconfigurationaspect.cpp qmlprofilerrunconfigurationaspect.h
qmlprofilerruncontrol.cpp qmlprofilerruncontrol.h qmlprofilerruncontrol.cpp qmlprofilerruncontrol.h

View File

@@ -40,7 +40,7 @@ QtcPlugin {
"qmlprofilereventtypes.h", "qmlprofilereventtypes.h",
"qmlprofilermodelmanager.cpp", "qmlprofilermodelmanager.h", "qmlprofilermodelmanager.cpp", "qmlprofilermodelmanager.h",
"qmlprofilernotesmodel.cpp", "qmlprofilernotesmodel.h", "qmlprofilernotesmodel.cpp", "qmlprofilernotesmodel.h",
"qmlprofilerplugin.cpp", "qmlprofilerplugin.h", "qmlprofilerplugin.cpp",
"qmlprofilerrunconfigurationaspect.cpp", "qmlprofilerrunconfigurationaspect.h", "qmlprofilerrunconfigurationaspect.cpp", "qmlprofilerrunconfigurationaspect.h",
"qmlprofilerrangemodel.cpp", "qmlprofilerrangemodel.h", "qmlprofilerrangemodel.cpp", "qmlprofilerrangemodel.h",
"qmlprofilerruncontrol.cpp", "qmlprofilerruncontrol.h", "qmlprofilerruncontrol.cpp", "qmlprofilerruncontrol.h",

View File

@@ -1,7 +1,6 @@
// Copyright (C) 2016 The Qt Company Ltd. // Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmlprofilerplugin.h"
#include "qmlprofilerrunconfigurationaspect.h" #include "qmlprofilerrunconfigurationaspect.h"
#include "qmlprofilerruncontrol.h" #include "qmlprofilerruncontrol.h"
#include "qmlprofilersettings.h" #include "qmlprofilersettings.h"
@@ -48,20 +47,22 @@
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <extensionsystem/iplugin.h>
using namespace ProjectExplorer; using namespace ProjectExplorer;
namespace QmlProfiler::Internal { namespace QmlProfiler::Internal {
class QmlProfilerPluginPrivate class QmlProfilerPlugin final : public ExtensionSystem::IPlugin
{ {
public: Q_OBJECT
QmlProfilerTool m_profilerTool; Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlProfiler.json")
};
bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString) bool initialize(const QStringList &arguments, QString *errorString) final
{ {
Q_UNUSED(arguments) Q_UNUSED(arguments)
setupQmlProfilerTool();
setupQmlProfilerRunning(); setupQmlProfilerRunning();
#ifdef WITH_TESTS #ifdef WITH_TESTS
@@ -89,24 +90,21 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
#endif #endif
return Utils::HostOsInfo::canCreateOpenGLContext(errorString); return Utils::HostOsInfo::canCreateOpenGLContext(errorString);
} }
void QmlProfilerPlugin::extensionsInitialized()
{
d = new QmlProfilerPluginPrivate;
void extensionsInitialized() final
{
RunConfiguration::registerAspect<QmlProfilerRunConfigurationAspect>(); RunConfiguration::registerAspect<QmlProfilerRunConfigurationAspect>();
} }
ExtensionSystem::IPlugin::ShutdownFlag QmlProfilerPlugin::aboutToShutdown() ShutdownFlag aboutToShutdown() final
{ {
delete d; destroyQmlProfilerTool();
d = nullptr;
// Save settings.
// Disconnect from signals that are not needed during shutdown
// Hide UI (if you add UI that is not in the main window directly)
return SynchronousShutdown; return SynchronousShutdown;
} }
};
} // QmlProfiler::Internal } // QmlProfiler::Internal
#include "qmlprofilerplugin.moc"

View File

@@ -1,23 +0,0 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <extensionsystem/iplugin.h>
namespace QmlProfiler::Internal {
class QmlProfilerPlugin : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlProfiler.json")
private:
bool initialize(const QStringList &arguments, QString *errorString) final;
void extensionsInitialized() final;
ShutdownFlag aboutToShutdown() final;
class QmlProfilerPluginPrivate *d = nullptr;
};
} // QmlProfiler::Internal

View File

@@ -7,7 +7,6 @@
#include "qmlprofilerclientmanager.h" #include "qmlprofilerclientmanager.h"
#include "qmlprofilerconstants.h" #include "qmlprofilerconstants.h"
#include "qmlprofilermodelmanager.h" #include "qmlprofilermodelmanager.h"
#include "qmlprofilerplugin.h"
#include "qmlprofilerrunconfigurationaspect.h" #include "qmlprofilerrunconfigurationaspect.h"
#include "qmlprofilerruncontrol.h" #include "qmlprofilerruncontrol.h"
#include "qmlprofilersettings.h" #include "qmlprofilersettings.h"
@@ -75,8 +74,7 @@ using namespace QmlProfiler::Constants;
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
namespace QmlProfiler { namespace QmlProfiler::Internal {
namespace Internal {
static QmlProfilerTool *m_instance = nullptr; static QmlProfilerTool *m_instance = nullptr;
@@ -922,5 +920,14 @@ void QmlProfilerTool::toggleVisibleFeature(QAction *action)
d->m_profilerModelManager->visibleFeatures() & (~(1ULL << feature))); d->m_profilerModelManager->visibleFeatures() & (~(1ULL << feature)));
} }
} // namespace Internal void setupQmlProfilerTool()
} // namespace QmlProfiler {
(void) new QmlProfilerTool;
}
void destroyQmlProfilerTool()
{
delete m_instance;
}
} // QmlProfiler::Internal

View File

@@ -89,5 +89,8 @@ private:
QmlProfilerToolPrivate *d; QmlProfilerToolPrivate *d;
}; };
void setupQmlProfilerTool();
void destroyQmlProfilerTool();
} // namespace Internal } // namespace Internal
} // namespace QmlProfiler } // namespace QmlProfiler

View File

@@ -4,7 +4,6 @@
#include "qmlprofileranimationsmodel.h" #include "qmlprofileranimationsmodel.h"
#include "qmlprofilermodelmanager.h" #include "qmlprofilermodelmanager.h"
#include "qmlprofilernotesmodel.h" #include "qmlprofilernotesmodel.h"
#include "qmlprofilerplugin.h"
#include "qmlprofilerrangemodel.h" #include "qmlprofilerrangemodel.h"
#include "qmlprofilerstatemanager.h" #include "qmlprofilerstatemanager.h"
#include "qmlprofilertool.h" #include "qmlprofilertool.h"