From b8dbc734c1a9b950a9796a99b9ef427b7e132820 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Fri, 10 Jul 2015 13:56:19 +0200 Subject: [PATCH] fix clash of plugins of different type with the same name --- src/libsnore/plugins/plugins.cpp | 2 +- src/libsnore/snore.cpp | 4 ++-- src/libsnore/snore_p.cpp | 5 +++-- src/libsnore/snore_p.h | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libsnore/plugins/plugins.cpp b/src/libsnore/plugins/plugins.cpp index 3ff0137..9f7a42d 100644 --- a/src/libsnore/plugins/plugins.cpp +++ b/src/libsnore/plugins/plugins.cpp @@ -85,7 +85,7 @@ Snore::PluginSettingsWidget *SnorePlugin::settingsWidget() QString SnorePlugin::normaliseKey(const QString &key) const { - return name() + QLatin1Char('/') + key + QLatin1Char('.') + settingsVersion(); + return name() + QLatin1Char('-') + typeName() + QLatin1Char('/') + key + QLatin1Char('.') + settingsVersion(); } const QString &SnorePlugin::name() const diff --git a/src/libsnore/snore.cpp b/src/libsnore/snore.cpp index c21112f..63ed80d 100644 --- a/src/libsnore/snore.cpp +++ b/src/libsnore/snore.cpp @@ -99,7 +99,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types) } snoreDebug(SNORE_DEBUG) << info->name() << "is a" << info->type(); d->m_pluginNames[info->type()].append(info->name()); - d->m_plugins[info->name()] = plugin; + d->m_plugins[qMakePair(type, info->name())] = plugin; } if (d->m_pluginNames.contains(type)) { qSort(d->m_pluginNames[type]); @@ -194,7 +194,7 @@ QList SnoreCore::settingWidgets(SnorePlugin::PluginTypes QList list; for (auto name : d->m_pluginNames[type]) { //TODO: mem leak? - SnorePlugin *p = d->m_plugins[name]; + SnorePlugin *p = d->m_plugins[qMakePair(type, name)]; PluginSettingsWidget *widget = p->settingsWidget(); if (widget) { list.append(widget); diff --git a/src/libsnore/snore_p.cpp b/src/libsnore/snore_p.cpp index b7f9efb..ce7d0f2 100644 --- a/src/libsnore/snore_p.cpp +++ b/src/libsnore/snore_p.cpp @@ -176,8 +176,9 @@ void SnoreCorePrivate::syncSettings() types.removeOne(SnorePlugin::BACKEND); for (auto type : types) { for (auto &pluginName : m_pluginNames[type]) { - SnorePlugin *plugin = m_plugins.value(pluginName); - bool enable = m_plugins[pluginName]->settingsValue(QLatin1String("Enabled"), LOCAL_SETTING).toBool(); + auto key = qMakePair(type, pluginName); + SnorePlugin *plugin = m_plugins.value(key); + bool enable = m_plugins[key]->settingsValue(QLatin1String("Enabled"), LOCAL_SETTING).toBool(); if (!plugin->isInitialized() && enable) { plugin->initialize(); } else if (plugin->isInitialized() && !enable) { diff --git a/src/libsnore/snore_p.h b/src/libsnore/snore_p.h index 94222c3..f4ba7cf 100644 --- a/src/libsnore/snore_p.h +++ b/src/libsnore/snore_p.h @@ -94,7 +94,7 @@ private: QHash m_applications; QHash m_pluginNames; - QHash m_plugins; + QHash, SnorePlugin *> m_plugins; QPointer m_notificationBackend;