fix clash of plugins of different type with the same name

This commit is contained in:
Patrick von Reth 2015-07-10 13:56:19 +02:00
parent a586ca60e3
commit b8dbc734c1
4 changed files with 7 additions and 6 deletions

View File

@ -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

View File

@ -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<PluginSettingsWidget *> SnoreCore::settingWidgets(SnorePlugin::PluginTypes
QList<PluginSettingsWidget *> 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);

View File

@ -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) {

View File

@ -94,7 +94,7 @@ private:
QHash<QString, Application> m_applications;
QHash<SnorePlugin::PluginTypes, QStringList> m_pluginNames;
QHash<QString, SnorePlugin *> m_plugins;
QHash<QPair<SnorePlugin::PluginTypes, QString>, SnorePlugin *> m_plugins;
QPointer<SnoreBackend> m_notificationBackend;