don't crash if no primary backends are avalible

This commit is contained in:
Patrick von Reth 2015-05-19 14:42:25 +02:00
parent 737e289167
commit d795a81a1d
1 changed files with 12 additions and 6 deletions

View File

@ -146,13 +146,19 @@ void SnoreCorePrivate::init()
void SnoreCorePrivate::syncSettings() void SnoreCorePrivate::syncSettings()
{ {
Q_Q(SnoreCore); Q_Q(SnoreCore);
QString oldBackend = q->primaryNotificationBackend(); QString newBackend = q->value("PrimaryBackend", LOCAL_SETTING);
if (newBackend) {
QString oldBackend;
if (m_notificationBackend) {
oldBackend = m_notificationBackend->name();
m_notificationBackend->deinitialize(); m_notificationBackend->deinitialize();
m_notificationBackend = nullptr; m_notificationBackend = nullptr;
if (!setBackendIfAvailible(q->value("PrimaryBackend", LOCAL_SETTING).toString())) { }
if (!setBackendIfAvailible(newBackend)) {
snoreDebug(SNORE_WARNING) << "Failed to set new backend" << q->value("PrimaryBackend", LOCAL_SETTING).toString() << "restoring" << oldBackend; snoreDebug(SNORE_WARNING) << "Failed to set new backend" << q->value("PrimaryBackend", LOCAL_SETTING).toString() << "restoring" << oldBackend;
setBackendIfAvailible(oldBackend); setBackendIfAvailible(oldBackend);
} }
}
//TODO: cleanup //TODO: cleanup
auto syncPluginStatus = [&](const QString & pluginName) { auto syncPluginStatus = [&](const QString & pluginName) {
SnorePlugin *plugin = m_plugins.value(pluginName); SnorePlugin *plugin = m_plugins.value(pluginName);