From 0f71b27c71155dc9cdb1a47814731766b0f0c20e Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 18 Nov 2021 12:38:44 +0000 Subject: [PATCH] Ensure binary effects are loaded before cleints The current code performed two functions: - metadata was read async - the event loop is spun between each effect loading After we merged static and binary plugins this caused a problem for things like blur and background contrast where loading an effect influences what we advertise as supported. We don't want plasmashell to have to reload all it's SVGs. All KDE provided binary plugins are statically bundled so querying for plugins is super duper fast anyway. It's not the same kbuildsycococa path that it used to be. The C++ plugins tend to be considerably faster in their constructor than scripted counterparts, and if anything should be loaded lazily it can be handled inside the effect. --- src/effectloader.cpp | 28 ++++++---------------------- src/effectloader.h | 2 -- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/effectloader.cpp b/src/effectloader.cpp index 5fbb33e6bf..84111d0a0e 100644 --- a/src/effectloader.cpp +++ b/src/effectloader.cpp @@ -194,7 +194,6 @@ void ScriptedEffectLoader::clear() PluginEffectLoader::PluginEffectLoader(QObject *parent) : AbstractEffectLoader(parent) - , m_queue(new EffectLoadQueue< PluginEffectLoader, KPluginMetaData>(this)) , m_pluginSubDirectory(QStringLiteral("kwin/effects/plugins")) { } @@ -332,25 +331,13 @@ bool PluginEffectLoader::loadEffect(const KPluginMetaData &info, LoadEffectFlags void PluginEffectLoader::queryAndLoadAll() { - if (m_queryConnection) { - return; + const auto effects = findAllEffects(); + for (const auto &effect : effects) { + const LoadEffectFlags flags = readConfig(effect.pluginId(), effect.isEnabledByDefault()); + if (flags.testFlag(LoadEffectFlag::Load)) { + loadEffect(effect, flags); + } } - // perform querying for the services in a thread - QFutureWatcher> *watcher = new QFutureWatcher>(this); - m_queryConnection = connect(watcher, &QFutureWatcher>::finished, this, - [this, watcher]() { - const auto effects = watcher->result(); - for (const auto &effect : effects) { - const LoadEffectFlags flags = readConfig(effect.pluginId(), effect.isEnabledByDefault()); - if (flags.testFlag(LoadEffectFlag::Load)) { - m_queue->enqueue(qMakePair(effect, flags)); - } - } - watcher->deleteLater(); - m_queryConnection = QMetaObject::Connection(); - }, - Qt::QueuedConnection); - watcher->setFuture(QtConcurrent::run(this, &PluginEffectLoader::findAllEffects)); } QVector PluginEffectLoader::findAllEffects() const @@ -365,9 +352,6 @@ void PluginEffectLoader::setPluginSubDirectory(const QString &directory) void PluginEffectLoader::clear() { - disconnect(m_queryConnection); - m_queryConnection = QMetaObject::Connection(); - m_queue->clear(); } EffectLoader::EffectLoader(QObject *parent) diff --git a/src/effectloader.h b/src/effectloader.h index 4b0594564b..8c2a132b19 100644 --- a/src/effectloader.h +++ b/src/effectloader.h @@ -317,9 +317,7 @@ private: KPluginMetaData findEffect(const QString &name) const; EffectPluginFactory *factory(const KPluginMetaData &info) const; QStringList m_loadedEffects; - EffectLoadQueue< PluginEffectLoader, KPluginMetaData> *m_queue; QString m_pluginSubDirectory; - QMetaObject::Connection m_queryConnection; }; class KWIN_EXPORT EffectLoader : public AbstractEffectLoader