Cancel loading in EffectsLoader on tear down
When unloading all effects we should make sure that also the ones scheduled for loading are canceled. For this a new method clear() is added to the AbstractEffectLoader and all inheriting classes which clears the current load queue. For the scripted and plugin effect loader it should also cancel the future, but that's not yet implemented.
This commit is contained in:
parent
e5a0af1589
commit
deb63fa344
3 changed files with 42 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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<AbstractEffectLoader*> m_loaders;
|
||||
|
|
|
@ -336,6 +336,7 @@ void EffectsHandlerImpl::unloadAllEffects()
|
|||
delete effect;
|
||||
}
|
||||
loaded_effects.clear();
|
||||
m_effectLoader->clear();
|
||||
}
|
||||
|
||||
void EffectsHandlerImpl::setupAbstractClientConnections(AbstractClient* c)
|
||||
|
|
Loading…
Reference in a new issue