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.
This commit is contained in:
parent
70a2fb877a
commit
0f71b27c71
2 changed files with 6 additions and 24 deletions
|
@ -194,7 +194,6 @@ void ScriptedEffectLoader::clear()
|
||||||
|
|
||||||
PluginEffectLoader::PluginEffectLoader(QObject *parent)
|
PluginEffectLoader::PluginEffectLoader(QObject *parent)
|
||||||
: AbstractEffectLoader(parent)
|
: AbstractEffectLoader(parent)
|
||||||
, m_queue(new EffectLoadQueue< PluginEffectLoader, KPluginMetaData>(this))
|
|
||||||
, m_pluginSubDirectory(QStringLiteral("kwin/effects/plugins"))
|
, m_pluginSubDirectory(QStringLiteral("kwin/effects/plugins"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -332,25 +331,13 @@ bool PluginEffectLoader::loadEffect(const KPluginMetaData &info, LoadEffectFlags
|
||||||
|
|
||||||
void PluginEffectLoader::queryAndLoadAll()
|
void PluginEffectLoader::queryAndLoadAll()
|
||||||
{
|
{
|
||||||
if (m_queryConnection) {
|
const auto effects = findAllEffects();
|
||||||
return;
|
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<QVector<KPluginMetaData>> *watcher = new QFutureWatcher<QVector<KPluginMetaData>>(this);
|
|
||||||
m_queryConnection = connect(watcher, &QFutureWatcher<QVector<KPluginMetaData>>::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<KPluginMetaData> PluginEffectLoader::findAllEffects() const
|
QVector<KPluginMetaData> PluginEffectLoader::findAllEffects() const
|
||||||
|
@ -365,9 +352,6 @@ void PluginEffectLoader::setPluginSubDirectory(const QString &directory)
|
||||||
|
|
||||||
void PluginEffectLoader::clear()
|
void PluginEffectLoader::clear()
|
||||||
{
|
{
|
||||||
disconnect(m_queryConnection);
|
|
||||||
m_queryConnection = QMetaObject::Connection();
|
|
||||||
m_queue->clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectLoader::EffectLoader(QObject *parent)
|
EffectLoader::EffectLoader(QObject *parent)
|
||||||
|
|
|
@ -317,9 +317,7 @@ private:
|
||||||
KPluginMetaData findEffect(const QString &name) const;
|
KPluginMetaData findEffect(const QString &name) const;
|
||||||
EffectPluginFactory *factory(const KPluginMetaData &info) const;
|
EffectPluginFactory *factory(const KPluginMetaData &info) const;
|
||||||
QStringList m_loadedEffects;
|
QStringList m_loadedEffects;
|
||||||
EffectLoadQueue< PluginEffectLoader, KPluginMetaData> *m_queue;
|
|
||||||
QString m_pluginSubDirectory;
|
QString m_pluginSubDirectory;
|
||||||
QMetaObject::Connection m_queryConnection;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class KWIN_EXPORT EffectLoader : public AbstractEffectLoader
|
class KWIN_EXPORT EffectLoader : public AbstractEffectLoader
|
||||||
|
|
Loading…
Reference in a new issue