move PluginManager singleton to Application

This commit is contained in:
Xaver Hugl 2022-07-20 11:52:22 +02:00
parent 4121d45c42
commit 45d4677973
5 changed files with 17 additions and 13 deletions

View file

@ -266,7 +266,7 @@ void Application::createOptions()
void Application::createPlugins() void Application::createPlugins()
{ {
PluginManager::create(this); m_pluginManager = std::make_unique<PluginManager>();
} }
void Application::createColorManager() void Application::createColorManager()
@ -306,7 +306,7 @@ void Application::destroyCompositor()
void Application::destroyPlugins() void Application::destroyPlugins()
{ {
delete PluginManager::self(); m_pluginManager.reset();
} }
void Application::destroyColorManager() void Application::destroyColorManager()
@ -562,4 +562,9 @@ void Application::initPlatform(const KPluginMetaData &plugin)
} }
} }
PluginManager *Application::pluginManager() const
{
return m_pluginManager.get();
}
} // namespace } // namespace

View file

@ -15,6 +15,7 @@
#include <kwinglobals.h> #include <kwinglobals.h>
#include <KSharedConfig> #include <KSharedConfig>
#include <memory>
// Qt // Qt
#include <QAbstractNativeEventFilter> #include <QAbstractNativeEventFilter>
#include <QApplication> #include <QApplication>
@ -28,6 +29,7 @@ namespace KWin
class Platform; class Platform;
class X11EventFilter; class X11EventFilter;
class PluginManager;
class XcbEventFilter : public QAbstractNativeEventFilter class XcbEventFilter : public QAbstractNativeEventFilter
{ {
@ -238,6 +240,8 @@ public:
static void setupMalloc(); static void setupMalloc();
static void setupLocalizedString(); static void setupLocalizedString();
PluginManager *pluginManager() const;
Q_SIGNALS: Q_SIGNALS:
void x11ConnectionChanged(); void x11ConnectionChanged();
void x11ConnectionAboutToBeDestroyed(); void x11ConnectionAboutToBeDestroyed();
@ -293,6 +297,7 @@ private:
bool m_terminating = false; bool m_terminating = false;
qreal m_xwaylandScale = 1; qreal m_xwaylandScale = 1;
QProcessEnvironment m_processEnvironment; QProcessEnvironment m_processEnvironment;
std::unique_ptr<PluginManager> m_pluginManager;
}; };
inline static Application *kwinApp() inline static Application *kwinApp()

View file

@ -17,8 +17,6 @@
namespace KWin namespace KWin
{ {
KWIN_SINGLETON_FACTORY(PluginManager)
static const QString s_pluginDirectory = QStringLiteral("kwin/plugins"); static const QString s_pluginDirectory = QStringLiteral("kwin/plugins");
static QJsonValue readPluginInfo(const QJsonObject &metadata, const QString &key) static QJsonValue readPluginInfo(const QJsonObject &metadata, const QString &key)
@ -26,8 +24,7 @@ static QJsonValue readPluginInfo(const QJsonObject &metadata, const QString &key
return metadata.value(QLatin1String("KPlugin")).toObject().value(key); return metadata.value(QLatin1String("KPlugin")).toObject().value(key);
} }
PluginManager::PluginManager(QObject *parent) PluginManager::PluginManager()
: QObject(parent)
{ {
const KConfigGroup config(kwinApp()->config(), QStringLiteral("Plugins")); const KConfigGroup config(kwinApp()->config(), QStringLiteral("Plugins"));
@ -77,10 +74,7 @@ PluginManager::PluginManager(QObject *parent)
new PluginManagerDBusInterface(this); new PluginManagerDBusInterface(this);
} }
PluginManager::~PluginManager() PluginManager::~PluginManager() = default;
{
s_self = nullptr;
}
QStringList PluginManager::loadedPlugins() const QStringList PluginManager::loadedPlugins() const
{ {

View file

@ -28,6 +28,7 @@ class KWIN_EXPORT PluginManager : public QObject
Q_OBJECT Q_OBJECT
public: public:
PluginManager();
~PluginManager() override; ~PluginManager() override;
QStringList loadedPlugins() const; QStringList loadedPlugins() const;
@ -45,7 +46,6 @@ private:
std::map<QString, std::unique_ptr<Plugin>> m_plugins; std::map<QString, std::unique_ptr<Plugin>> m_plugins;
QHash<QString, QStaticPlugin> m_staticPlugins; QHash<QString, QStaticPlugin> m_staticPlugins;
KWIN_SINGLETON(PluginManager)
}; };
} // namespace KWin } // namespace KWin

View file

@ -1724,14 +1724,14 @@ QString Workspace::supportInformation() const
} }
support.append(QLatin1String("\nLoaded Plugins:\n")); support.append(QLatin1String("\nLoaded Plugins:\n"));
support.append(QLatin1String("---------------\n")); support.append(QLatin1String("---------------\n"));
QStringList loadedPlugins = PluginManager::self()->loadedPlugins(); QStringList loadedPlugins = kwinApp()->pluginManager()->loadedPlugins();
loadedPlugins.sort(); loadedPlugins.sort();
for (const QString &plugin : qAsConst(loadedPlugins)) { for (const QString &plugin : qAsConst(loadedPlugins)) {
support.append(plugin + QLatin1Char('\n')); support.append(plugin + QLatin1Char('\n'));
} }
support.append(QLatin1String("\nAvailable Plugins:\n")); support.append(QLatin1String("\nAvailable Plugins:\n"));
support.append(QLatin1String("------------------\n")); support.append(QLatin1String("------------------\n"));
QStringList availablePlugins = PluginManager::self()->availablePlugins(); QStringList availablePlugins = kwinApp()->pluginManager()->availablePlugins();
availablePlugins.sort(); availablePlugins.sort();
for (const QString &plugin : qAsConst(availablePlugins)) { for (const QString &plugin : qAsConst(availablePlugins)) {
support.append(plugin + QLatin1Char('\n')); support.append(plugin + QLatin1Char('\n'));