fix clash of plugins of different type with the same name
This commit is contained in:
parent
a586ca60e3
commit
b8dbc734c1
|
@ -85,7 +85,7 @@ Snore::PluginSettingsWidget *SnorePlugin::settingsWidget()
|
||||||
|
|
||||||
QString SnorePlugin::normaliseKey(const QString &key) const
|
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
|
const QString &SnorePlugin::name() const
|
||||||
|
|
|
@ -99,7 +99,7 @@ void SnoreCore::loadPlugins(SnorePlugin::PluginTypes types)
|
||||||
}
|
}
|
||||||
snoreDebug(SNORE_DEBUG) << info->name() << "is a" << info->type();
|
snoreDebug(SNORE_DEBUG) << info->name() << "is a" << info->type();
|
||||||
d->m_pluginNames[info->type()].append(info->name());
|
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)) {
|
if (d->m_pluginNames.contains(type)) {
|
||||||
qSort(d->m_pluginNames[type]);
|
qSort(d->m_pluginNames[type]);
|
||||||
|
@ -194,7 +194,7 @@ QList<PluginSettingsWidget *> SnoreCore::settingWidgets(SnorePlugin::PluginTypes
|
||||||
QList<PluginSettingsWidget *> list;
|
QList<PluginSettingsWidget *> list;
|
||||||
for (auto name : d->m_pluginNames[type]) {
|
for (auto name : d->m_pluginNames[type]) {
|
||||||
//TODO: mem leak?
|
//TODO: mem leak?
|
||||||
SnorePlugin *p = d->m_plugins[name];
|
SnorePlugin *p = d->m_plugins[qMakePair(type, name)];
|
||||||
PluginSettingsWidget *widget = p->settingsWidget();
|
PluginSettingsWidget *widget = p->settingsWidget();
|
||||||
if (widget) {
|
if (widget) {
|
||||||
list.append(widget);
|
list.append(widget);
|
||||||
|
|
|
@ -176,8 +176,9 @@ void SnoreCorePrivate::syncSettings()
|
||||||
types.removeOne(SnorePlugin::BACKEND);
|
types.removeOne(SnorePlugin::BACKEND);
|
||||||
for (auto type : types) {
|
for (auto type : types) {
|
||||||
for (auto &pluginName : m_pluginNames[type]) {
|
for (auto &pluginName : m_pluginNames[type]) {
|
||||||
SnorePlugin *plugin = m_plugins.value(pluginName);
|
auto key = qMakePair(type, pluginName);
|
||||||
bool enable = m_plugins[pluginName]->settingsValue(QLatin1String("Enabled"), LOCAL_SETTING).toBool();
|
SnorePlugin *plugin = m_plugins.value(key);
|
||||||
|
bool enable = m_plugins[key]->settingsValue(QLatin1String("Enabled"), LOCAL_SETTING).toBool();
|
||||||
if (!plugin->isInitialized() && enable) {
|
if (!plugin->isInitialized() && enable) {
|
||||||
plugin->initialize();
|
plugin->initialize();
|
||||||
} else if (plugin->isInitialized() && !enable) {
|
} else if (plugin->isInitialized() && !enable) {
|
||||||
|
|
|
@ -94,7 +94,7 @@ private:
|
||||||
QHash<QString, Application> m_applications;
|
QHash<QString, Application> m_applications;
|
||||||
|
|
||||||
QHash<SnorePlugin::PluginTypes, QStringList> m_pluginNames;
|
QHash<SnorePlugin::PluginTypes, QStringList> m_pluginNames;
|
||||||
QHash<QString, SnorePlugin *> m_plugins;
|
QHash<QPair<SnorePlugin::PluginTypes, QString>, SnorePlugin *> m_plugins;
|
||||||
|
|
||||||
QPointer<SnoreBackend> m_notificationBackend;
|
QPointer<SnoreBackend> m_notificationBackend;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue