Commit 0e8b8037 authored by David Redondo's avatar David Redondo 🏎
Browse files

Do not load multiple versions of the same plugin

In instantiatePlugins the plugins are ordered according to the configured
libraries paths of the environment. When we load the plugins we are currently
doing the opposite of what we want. We load first the plugin from the directory
with the highest priority, some time later we load the same plugin from a
folder with a lower priority and then use the containers from this plugin and throw
the existing containers away!


(cherry picked from commit ee18830a)
parent ad3911b4
......@@ -80,15 +80,16 @@ void KSysGuardDaemon::init()
void KSysGuardDaemon::loadProviders()
{
//instantiate all plugins
const auto plugins = KPluginLoader::instantiatePlugins(QStringLiteral("ksysguard"), [this](const KPluginMetaData &metaData) {
QSet<QString> knownPlugins;
std::for_each(m_providers.cbegin(), m_providers.cend(), [&knownPlugins] (const SensorPlugin *plugin) {
knownPlugins.insert(plugin->providerName());
});
const auto plugins = KPluginLoader::instantiatePlugins(QStringLiteral("ksysguard"), [this, &knownPlugins](const KPluginMetaData &metaData) {
auto providerName = metaData.rawData().value("providerName").toString();
auto itr = std::find_if(m_providers.cbegin(), m_providers.cend(), [providerName](SensorPlugin *plugin) {
return plugin->providerName() == providerName;
});
if (itr != m_providers.cend()) {
if (knownPlugins.contains(providerName)) {
return false;
}
knownPlugins.insert(providerName);
return true;
}, this);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment