diff --git a/effectloader.cpp b/effectloader.cpp index f042feb1d5..ee85ac43e3 100644 --- a/effectloader.cpp +++ b/effectloader.cpp @@ -178,6 +178,11 @@ QString BuiltInEffectLoader::internalName(const QString& name) const return name.toLower(); } +void BuiltInEffectLoader::clear() +{ + m_queue->clear(); +} + static const QString s_nameProperty = QStringLiteral("X-KDE-PluginInfo-Name"); static const QString s_jsConstraint = QStringLiteral("[X-Plasma-API] == 'javascript'"); static const QString s_serviceType = QStringLiteral("KWin/Effect"); @@ -289,6 +294,12 @@ KPluginMetaData ScriptedEffectLoader::findEffect(const QString &name) const } +void ScriptedEffectLoader::clear() +{ + // TODO: cancel future + m_queue->clear(); +} + PluginEffectLoader::PluginEffectLoader(QObject *parent) : AbstractEffectLoader(parent) , m_queue(new EffectLoadQueue< PluginEffectLoader, KPluginMetaData>(this)) @@ -448,6 +459,12 @@ void PluginEffectLoader::setPluginSubDirectory(const QString &directory) m_pluginSubDirectory = directory; } +void PluginEffectLoader::clear() +{ + // TODO: cancel future + m_queue->clear(); +} + EffectLoader::EffectLoader(QObject *parent) : AbstractEffectLoader(parent) { @@ -513,4 +530,11 @@ void EffectLoader::setConfig(KSharedConfig::Ptr config) } } +void EffectLoader::clear() +{ + for (auto it = m_loaders.constBegin(); it != m_loaders.constEnd(); ++it) { + (*it)->clear(); + } +} + } // namespace KWin diff --git a/effectloader.h b/effectloader.h index 7fcb8e7643..38ca86a26a 100644 --- a/effectloader.h +++ b/effectloader.h @@ -162,6 +162,11 @@ public: */ virtual bool isEffectSupported(const QString &name) const = 0; + /** + * @brief Clears the load queue, that is all scheduled Effects are discarded from loading. + **/ + virtual void clear() = 0; + Q_SIGNALS: /** * @brief The loader emits this signal when it successfully loaded an effect. @@ -236,10 +241,17 @@ public: m_queue.enqueue(value); scheduleDequeue(); } + void clear() + { + m_queue.clear(); + m_dequeueScheduled = false; + } protected: void dequeue() override { - Q_ASSERT(!m_queue.isEmpty()); + if (m_queue.isEmpty()) { + return; + } m_dequeueScheduled = false; const auto pair = m_queue.dequeue(); m_effectLoader->loadEffect(pair.first, pair.second); @@ -274,6 +286,7 @@ public: bool isEffectSupported(const QString &name) const override; QStringList listOfKnownEffects() const override; + void clear() override; void queryAndLoadAll() override; bool loadEffect(const QString& name) override; bool loadEffect(BuiltInEffect effect, LoadEffectFlags flags); @@ -300,6 +313,7 @@ public: bool isEffectSupported(const QString &name) const override; QStringList listOfKnownEffects() const override; + void clear() override; void queryAndLoadAll() override; bool loadEffect(const QString &name) override; bool loadEffect(const KPluginMetaData &effect, LoadEffectFlags flags); @@ -322,6 +336,7 @@ public: bool isEffectSupported(const QString &name) const override; QStringList listOfKnownEffects() const override; + void clear() override; void queryAndLoadAll() override; bool loadEffect(const QString &name) override; bool loadEffect(const KPluginMetaData &info, LoadEffectFlags flags); @@ -349,6 +364,7 @@ public: bool loadEffect(const QString &name) override; void queryAndLoadAll() override; void setConfig(KSharedConfig::Ptr config) override; + void clear() override; private: QList m_loaders; diff --git a/effects.cpp b/effects.cpp index 0f0ac4e3a3..ebb7520bc5 100644 --- a/effects.cpp +++ b/effects.cpp @@ -336,6 +336,7 @@ void EffectsHandlerImpl::unloadAllEffects() delete effect; } loaded_effects.clear(); + m_effectLoader->clear(); } void EffectsHandlerImpl::setupAbstractClientConnections(AbstractClient* c)