From 99aa8007c17abdd1a89dffc82a29dbf7b46f190e Mon Sep 17 00:00:00 2001
From: Orgad Shaneh <orgads@gmail.com>
Date: Thu, 9 Aug 2012 12:58:51 +0300
Subject: [PATCH] Remove NULL tests for Core::ICore::settings()

It cannot really be NULL

Change-Id: I7231e00754464347dc5750249f751cda7f831930
Reviewed-by: hjk <qthjk@ovi.com>
---
 .../cpptools/completionsettingspage.cpp       |  6 +-
 src/plugins/cpptools/cpptoolssettings.cpp     | 93 +++++++++----------
 src/plugins/designer/formeditorw.cpp          |  9 +-
 src/plugins/perforce/perforceplugin.cpp       |  3 +-
 .../projectexplorer/projectexplorer.cpp       | 89 +++++++++---------
 src/plugins/qmldesigner/qmldesignerplugin.cpp |  3 +-
 .../qmljseditor/quicktoolbarsettingspage.cpp  |  6 +-
 src/plugins/qmljstools/qmljstoolssettings.cpp | 77 ++++++++-------
 src/plugins/subversion/subversionplugin.cpp   |  6 +-
 .../texteditor/behaviorsettingspage.cpp       | 13 ++-
 .../texteditor/displaysettingspage.cpp        |  7 +-
 src/plugins/texteditor/fontsettingspage.cpp   |  3 +-
 .../highlightersettingspage.cpp               |  3 +-
 .../snippets/snippetssettingspage.cpp         | 22 ++---
 src/plugins/texteditor/texteditorsettings.cpp |  6 +-
 15 files changed, 160 insertions(+), 186 deletions(-)

diff --git a/src/plugins/cpptools/completionsettingspage.cpp b/src/plugins/cpptools/completionsettingspage.cpp
index 0e7ed917552..22e2d02a61f 100644
--- a/src/plugins/cpptools/completionsettingspage.cpp
+++ b/src/plugins/cpptools/completionsettingspage.cpp
@@ -47,8 +47,7 @@ CompletionSettingsPage::CompletionSettingsPage(QObject *parent)
     : TextEditor::TextEditorOptionsPage(parent)
     , m_page(0)
 {
-    if (QSettings *s = Core::ICore::settings())
-        m_commentsSettings.fromSettings(QLatin1String(CPPTOOLS_SETTINGSGROUP), s);
+    m_commentsSettings.fromSettings(QLatin1String(CPPTOOLS_SETTINGSGROUP), Core::ICore::settings());
 
     setId(QLatin1String("P.Completion"));
     setDisplayName(tr("Completion"));
@@ -142,8 +141,7 @@ void CompletionSettingsPage::apply()
     m_commentsSettings.m_enableDoxygen = m_page->enableDoxygenCheckBox->isChecked();
     m_commentsSettings.m_generateBrief = m_page->generateBriefCheckBox->isChecked();
     m_commentsSettings.m_leadingAsterisks = m_page->leadingAsterisksCheckBox->isChecked();
-    if (QSettings *s = Core::ICore::settings())
-        m_commentsSettings.toSettings(QLatin1String(CPPTOOLS_SETTINGSGROUP), s);
+    m_commentsSettings.toSettings(QLatin1String(CPPTOOLS_SETTINGSGROUP), Core::ICore::settings());
 
     emit commentsSettingsChanged(m_commentsSettings);
 }
diff --git a/src/plugins/cpptools/cpptoolssettings.cpp b/src/plugins/cpptools/cpptoolssettings.cpp
index 547d31e056c..31e611eb4d6 100644
--- a/src/plugins/cpptools/cpptoolssettings.cpp
+++ b/src/plugins/cpptools/cpptoolssettings.cpp
@@ -171,55 +171,54 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
     pool->loadCustomCodeStyles();
 
     // load global settings (after built-in settings are added to the pool)
-    if (QSettings *s = Core::ICore::settings()) {
-        d->m_globalCodeStyle->fromSettings(CppTools::Constants::CPP_SETTINGS_ID, s);
-
-        // legacy handling start (Qt Creator Version < 2.4)
-        const bool legacyTransformed =
-                    s->value(QLatin1String("CppCodeStyleSettings/LegacyTransformed"), false).toBool();
-
-        if (!legacyTransformed) {
-            // creator 2.4 didn't mark yet the transformation (first run of creator 2.4)
-
-            // we need to transform the settings only if at least one from
-            // below settings was already written - otherwise we use
-            // defaults like it would be the first run of creator 2.4 without stored settings
-            const QStringList groups = s->childGroups();
-            const bool needTransform = groups.contains(QLatin1String("textTabPreferences")) ||
-                                       groups.contains(QLatin1String("CppTabPreferences")) ||
-                                       groups.contains(QLatin1String("CppCodeStyleSettings"));
-            if (needTransform) {
-                CppCodeStyleSettings legacyCodeStyleSettings;
-                if (groups.contains(QLatin1String("CppCodeStyleSettings"))) {
-                    Utils::fromSettings(QLatin1String("CppCodeStyleSettings"),
-                                        QString(), s, &legacyCodeStyleSettings);
-                }
-
-                const QString currentFallback = s->value(QLatin1String("CppTabPreferences/CurrentFallback")).toString();
-                TabSettings legacyTabSettings;
-                if (currentFallback == QLatin1String("CppGlobal")) {
-                    // no delegate, global overwritten
-                    Utils::fromSettings(QLatin1String("CppTabPreferences"),
-                                        QString(), s, &legacyTabSettings);
-                } else {
-                    // delegating to global
-                    legacyTabSettings = textEditorSettings->codeStyle()->currentTabSettings();
-                }
-
-                // create custom code style out of old settings
-                QVariant v;
-                v.setValue(legacyCodeStyleSettings);
-                TextEditor::ICodeStylePreferences *oldCreator = pool->createCodeStyle(
-                         QLatin1String("legacy"), legacyTabSettings,
-                         v, tr("Old Creator"));
-
-                // change the current delegate and save
-                d->m_globalCodeStyle->setCurrentDelegate(oldCreator);
-                d->m_globalCodeStyle->toSettings(CppTools::Constants::CPP_SETTINGS_ID, s);
+    QSettings *s = Core::ICore::settings();
+    d->m_globalCodeStyle->fromSettings(CppTools::Constants::CPP_SETTINGS_ID, Core::ICore::settings());
+
+    // legacy handling start (Qt Creator Version < 2.4)
+    const bool legacyTransformed =
+                s->value(QLatin1String("CppCodeStyleSettings/LegacyTransformed"), false).toBool();
+
+    if (!legacyTransformed) {
+        // creator 2.4 didn't mark yet the transformation (first run of creator 2.4)
+
+        // we need to transform the settings only if at least one from
+        // below settings was already written - otherwise we use
+        // defaults like it would be the first run of creator 2.4 without stored settings
+        const QStringList groups = s->childGroups();
+        const bool needTransform = groups.contains(QLatin1String("textTabPreferences")) ||
+                                   groups.contains(QLatin1String("CppTabPreferences")) ||
+                                   groups.contains(QLatin1String("CppCodeStyleSettings"));
+        if (needTransform) {
+            CppCodeStyleSettings legacyCodeStyleSettings;
+            if (groups.contains(QLatin1String("CppCodeStyleSettings"))) {
+                Utils::fromSettings(QLatin1String("CppCodeStyleSettings"),
+                                    QString(), s, &legacyCodeStyleSettings);
             }
-            // mark old settings as transformed
-            s->setValue(QLatin1String("CppCodeStyleSettings/LegacyTransformed"), true);
+
+            const QString currentFallback = s->value(QLatin1String("CppTabPreferences/CurrentFallback")).toString();
+            TabSettings legacyTabSettings;
+            if (currentFallback == QLatin1String("CppGlobal")) {
+                // no delegate, global overwritten
+                Utils::fromSettings(QLatin1String("CppTabPreferences"),
+                                    QString(), s, &legacyTabSettings);
+            } else {
+                // delegating to global
+                legacyTabSettings = textEditorSettings->codeStyle()->currentTabSettings();
+            }
+
+            // create custom code style out of old settings
+            QVariant v;
+            v.setValue(legacyCodeStyleSettings);
+            TextEditor::ICodeStylePreferences *oldCreator = pool->createCodeStyle(
+                     QLatin1String("legacy"), legacyTabSettings,
+                     v, tr("Old Creator"));
+
+            // change the current delegate and save
+            d->m_globalCodeStyle->setCurrentDelegate(oldCreator);
+            d->m_globalCodeStyle->toSettings(CppTools::Constants::CPP_SETTINGS_ID, s);
         }
+        // mark old settings as transformed
+        s->setValue(QLatin1String("CppCodeStyleSettings/LegacyTransformed"), true);
         // legacy handling stop
     }
 
diff --git a/src/plugins/designer/formeditorw.cpp b/src/plugins/designer/formeditorw.cpp
index eaf9e7da495..77359a1d9f1 100644
--- a/src/plugins/designer/formeditorw.cpp
+++ b/src/plugins/designer/formeditorw.cpp
@@ -189,11 +189,10 @@ FormEditorW::~FormEditorW()
     if (m_context)
         Core::ICore::removeContextObject(m_context);
     if (m_initStage == FullyInitialized) {
-        if (QSettings *s = Core::ICore::settings()) {
-            s->beginGroup(QLatin1String(settingsGroupC));
-            m_editorWidget->saveSettings(s);
-            s->endGroup();
-        }
+        QSettings *s = Core::ICore::settings();
+        s->beginGroup(QLatin1String(settingsGroupC));
+        m_editorWidget->saveSettings(s);
+        s->endGroup();
 
         m_designMode->unregisterDesignWidget(m_modeWidget);
         delete m_modeWidget;
diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp
index a08b6501d69..a53d9ab2c3b 100644
--- a/src/plugins/perforce/perforceplugin.cpp
+++ b/src/plugins/perforce/perforceplugin.cpp
@@ -226,8 +226,7 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *er
         return false;
     m_perforcePluginInstance = this;
 
-    if (QSettings *settings = Core::ICore::settings())
-        m_settings.fromSettings(settings);
+    m_settings.fromSettings(Core::ICore::settings());
 
     addAutoReleasedObject(new SettingsPage);
 
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index a646124379c..63fb98569a2 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -887,59 +887,56 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
     addAutoReleasedObject(new FolderNavigationWidgetFactory);
     addAutoReleasedObject(new DeployConfigurationFactory);
 
-    if (QSettings *s = Core::ICore::settings()) {
-        const QStringList fileNames =
-                s->value(QLatin1String("ProjectExplorer/RecentProjects/FileNames")).toStringList();
-        const QStringList displayNames =
-                s->value(QLatin1String("ProjectExplorer/RecentProjects/DisplayNames")).toStringList();
-        if (fileNames.size() == displayNames.size()) {
-            for (int i = 0; i < fileNames.size(); ++i) {
-                if (QFileInfo(fileNames.at(i)).isFile())
-                    d->m_recentProjects.append(qMakePair(fileNames.at(i), displayNames.at(i)));
-            }
+    QSettings *s = Core::ICore::settings();
+    const QStringList fileNames =
+            s->value(QLatin1String("ProjectExplorer/RecentProjects/FileNames")).toStringList();
+    const QStringList displayNames =
+            s->value(QLatin1String("ProjectExplorer/RecentProjects/DisplayNames")).toStringList();
+    if (fileNames.size() == displayNames.size()) {
+        for (int i = 0; i < fileNames.size(); ++i) {
+            if (QFileInfo(fileNames.at(i)).isFile())
+                d->m_recentProjects.append(qMakePair(fileNames.at(i), displayNames.at(i)));
         }
     }
 
-    if (QSettings *s = Core::ICore::settings()) {
-        d->m_projectExplorerSettings.buildBeforeDeploy =
-                s->value(QLatin1String("ProjectExplorer/Settings/BuildBeforeDeploy"), true).toBool();
-        d->m_projectExplorerSettings.deployBeforeRun =
-                s->value(QLatin1String("ProjectExplorer/Settings/DeployBeforeRun"), true).toBool();
-        d->m_projectExplorerSettings.saveBeforeBuild =
-                s->value(QLatin1String("ProjectExplorer/Settings/SaveBeforeBuild"), false).toBool();
-        d->m_projectExplorerSettings.showCompilerOutput =
-                s->value(QLatin1String("ProjectExplorer/Settings/ShowCompilerOutput"), false).toBool();
-        d->m_projectExplorerSettings.showRunOutput =
-                s->value(QLatin1String("ProjectExplorer/Settings/ShowRunOutput"), true).toBool();
-        d->m_projectExplorerSettings.showDebugOutput =
-                s->value(QLatin1String("ProjectExplorer/Settings/ShowDebugOutput"), false).toBool();
-        d->m_projectExplorerSettings.cleanOldAppOutput =
-                s->value(QLatin1String("ProjectExplorer/Settings/CleanOldAppOutput"), false).toBool();
-        d->m_projectExplorerSettings.mergeStdErrAndStdOut =
-                s->value(QLatin1String("ProjectExplorer/Settings/MergeStdErrAndStdOut"), false).toBool();
-        d->m_projectExplorerSettings.wrapAppOutput =
-                s->value(QLatin1String("ProjectExplorer/Settings/WrapAppOutput"), true).toBool();
+    d->m_projectExplorerSettings.buildBeforeDeploy =
+            s->value(QLatin1String("ProjectExplorer/Settings/BuildBeforeDeploy"), true).toBool();
+    d->m_projectExplorerSettings.deployBeforeRun =
+            s->value(QLatin1String("ProjectExplorer/Settings/DeployBeforeRun"), true).toBool();
+    d->m_projectExplorerSettings.saveBeforeBuild =
+            s->value(QLatin1String("ProjectExplorer/Settings/SaveBeforeBuild"), false).toBool();
+    d->m_projectExplorerSettings.showCompilerOutput =
+            s->value(QLatin1String("ProjectExplorer/Settings/ShowCompilerOutput"), false).toBool();
+    d->m_projectExplorerSettings.showRunOutput =
+            s->value(QLatin1String("ProjectExplorer/Settings/ShowRunOutput"), true).toBool();
+    d->m_projectExplorerSettings.showDebugOutput =
+            s->value(QLatin1String("ProjectExplorer/Settings/ShowDebugOutput"), false).toBool();
+    d->m_projectExplorerSettings.cleanOldAppOutput =
+            s->value(QLatin1String("ProjectExplorer/Settings/CleanOldAppOutput"), false).toBool();
+    d->m_projectExplorerSettings.mergeStdErrAndStdOut =
+            s->value(QLatin1String("ProjectExplorer/Settings/MergeStdErrAndStdOut"), false).toBool();
+    d->m_projectExplorerSettings.wrapAppOutput =
+            s->value(QLatin1String("ProjectExplorer/Settings/WrapAppOutput"), true).toBool();
 #ifdef Q_OS_WIN
-        QFileInfo jom = QFileInfo(MsvcToolChain::findInstalledJom());
-        if (!jom.exists())
-            jom.setFile(Utils::Environment::systemEnvironment().searchInPath(QLatin1String("jom.exe")));
+    QFileInfo jom = QFileInfo(MsvcToolChain::findInstalledJom());
+    if (!jom.exists())
+        jom.setFile(Utils::Environment::systemEnvironment().searchInPath(QLatin1String("jom.exe")));
 
-        d->m_projectExplorerSettings.useJom =
-                s->value(QLatin1String("ProjectExplorer/Settings/UseJom"), jom.exists()).toBool();
+    d->m_projectExplorerSettings.useJom =
+            s->value(QLatin1String("ProjectExplorer/Settings/UseJom"), jom.exists()).toBool();
 #else
-        d->m_projectExplorerSettings.useJom = true; // No need to read any settings
+    d->m_projectExplorerSettings.useJom = true; // No need to read any settings
 #endif
-        d->m_projectExplorerSettings.autorestoreLastSession =
-                s->value(QLatin1String("ProjectExplorer/Settings/AutoRestoreLastSession"), false).toBool();
-        d->m_projectExplorerSettings.prompToStopRunControl =
-                s->value(QLatin1String("ProjectExplorer/Settings/PromptToStopRunControl"), false).toBool();
-        d->m_projectExplorerSettings.maxAppOutputLines =
-                s->value(QLatin1String("ProjectExplorer/Settings/MaxAppOutputLines"), 100000).toInt();
-        d->m_projectExplorerSettings.environmentId =
-                QUuid(s->value(QLatin1String("ProjectExplorer/Settings/EnvironmentId")).toString());
-        if (d->m_projectExplorerSettings.environmentId.isNull())
-            d->m_projectExplorerSettings.environmentId = QUuid::createUuid();
-    }
+    d->m_projectExplorerSettings.autorestoreLastSession =
+            s->value(QLatin1String("ProjectExplorer/Settings/AutoRestoreLastSession"), false).toBool();
+    d->m_projectExplorerSettings.prompToStopRunControl =
+            s->value(QLatin1String("ProjectExplorer/Settings/PromptToStopRunControl"), false).toBool();
+    d->m_projectExplorerSettings.maxAppOutputLines =
+            s->value(QLatin1String("ProjectExplorer/Settings/MaxAppOutputLines"), 100000).toInt();
+    d->m_projectExplorerSettings.environmentId =
+            QUuid(s->value(QLatin1String("ProjectExplorer/Settings/EnvironmentId")).toString());
+    if (d->m_projectExplorerSettings.environmentId.isNull())
+        d->m_projectExplorerSettings.environmentId = QUuid::createUuid();
 
     connect(d->m_sessionManagerAction, SIGNAL(triggered()), this, SLOT(showSessionManager()));
     connect(d->m_newAction, SIGNAL(triggered()), this, SLOT(newProject()));
diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp
index 6935e5cbc94..378d2dc9e36 100644
--- a/src/plugins/qmldesigner/qmldesignerplugin.cpp
+++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp
@@ -387,8 +387,7 @@ void BauhausPlugin::setSettings(const DesignerSettings &s)
 {
     if (s != m_settings) {
         m_settings = s;
-        if (QSettings *settings = Core::ICore::settings())
-            m_settings.toSettings(settings);
+        m_settings.toSettings(Core::ICore::settings());
     }
 }
 
diff --git a/src/plugins/qmljseditor/quicktoolbarsettingspage.cpp b/src/plugins/qmljseditor/quicktoolbarsettingspage.cpp
index 02907e4d6b4..6d90200ed7b 100644
--- a/src/plugins/qmljseditor/quicktoolbarsettingspage.cpp
+++ b/src/plugins/qmljseditor/quicktoolbarsettingspage.cpp
@@ -49,10 +49,8 @@ QuickToolBarSettings::QuickToolBarSettings()
 
 void QuickToolBarSettings::set()
 {
-    if (get() != *this) {
-        if (QSettings *settings = Core::ICore::settings())
-            toSettings(settings);
-    }
+    if (get() != *this)
+        toSettings(Core::ICore::settings());
 }
 
 void QuickToolBarSettings::fromSettings(QSettings *settings)
diff --git a/src/plugins/qmljstools/qmljstoolssettings.cpp b/src/plugins/qmljstools/qmljstoolssettings.cpp
index 6a72bedc6cf..442365bc2c2 100644
--- a/src/plugins/qmljstools/qmljstoolssettings.cpp
+++ b/src/plugins/qmljstools/qmljstoolssettings.cpp
@@ -107,47 +107,46 @@ QmlJSToolsSettings::QmlJSToolsSettings(QObject *parent)
     pool->loadCustomCodeStyles();
 
     // load global settings (after built-in settings are added to the pool)
-    if (QSettings *s = Core::ICore::settings()) {
-        d->m_globalCodeStyle->fromSettings(QmlJSTools::Constants::QML_JS_SETTINGS_ID, s);
-
-        // legacy handling start (Qt Creator Version < 2.4)
-        const bool legacyTransformed =
-                    s->value(QLatin1String("QmlJSTabPreferences/LegacyTransformed"), false).toBool();
-
-        if (!legacyTransformed) {
-            // creator 2.4 didn't mark yet the transformation (first run of creator 2.4)
-
-            // we need to transform the settings only if at least one from
-            // below settings was already written - otherwise we use
-            // defaults like it would be the first run of creator 2.4 without stored settings
-            const QStringList groups = s->childGroups();
-            const bool needTransform = groups.contains(QLatin1String("textTabPreferences")) ||
-                                       groups.contains(QLatin1String("QmlJSTabPreferences"));
-
-            if (needTransform) {
-                const QString currentFallback = s->value(QLatin1String("QmlJSTabPreferences/CurrentFallback")).toString();
-                TabSettings legacyTabSettings;
-                if (currentFallback == QLatin1String("QmlJSGlobal")) {
-                    // no delegate, global overwritten
-                    Utils::fromSettings(QLatin1String("QmlJSTabPreferences"),
-                                        QString(), s, &legacyTabSettings);
-                } else {
-                    // delegating to global
-                    legacyTabSettings = textEditorSettings->codeStyle()->currentTabSettings();
-                }
-
-                // create custom code style out of old settings
-                TextEditor::ICodeStylePreferences *oldCreator = pool->createCodeStyle(
-                         QLatin1String("legacy"), legacyTabSettings,
-                         QVariant(), tr("Old Creator"));
-
-                // change the current delegate and save
-                d->m_globalCodeStyle->setCurrentDelegate(oldCreator);
-                d->m_globalCodeStyle->toSettings(QmlJSTools::Constants::QML_JS_SETTINGS_ID, s);
+    QSettings *s = Core::ICore::settings();
+    d->m_globalCodeStyle->fromSettings(QmlJSTools::Constants::QML_JS_SETTINGS_ID, s);
+
+    // legacy handling start (Qt Creator Version < 2.4)
+    const bool legacyTransformed =
+                s->value(QLatin1String("QmlJSTabPreferences/LegacyTransformed"), false).toBool();
+
+    if (!legacyTransformed) {
+        // creator 2.4 didn't mark yet the transformation (first run of creator 2.4)
+
+        // we need to transform the settings only if at least one from
+        // below settings was already written - otherwise we use
+        // defaults like it would be the first run of creator 2.4 without stored settings
+        const QStringList groups = s->childGroups();
+        const bool needTransform = groups.contains(QLatin1String("textTabPreferences")) ||
+                                   groups.contains(QLatin1String("QmlJSTabPreferences"));
+
+        if (needTransform) {
+            const QString currentFallback = s->value(QLatin1String("QmlJSTabPreferences/CurrentFallback")).toString();
+            TabSettings legacyTabSettings;
+            if (currentFallback == QLatin1String("QmlJSGlobal")) {
+                // no delegate, global overwritten
+                Utils::fromSettings(QLatin1String("QmlJSTabPreferences"),
+                                    QString(), s, &legacyTabSettings);
+            } else {
+                // delegating to global
+                legacyTabSettings = textEditorSettings->codeStyle()->currentTabSettings();
             }
-            // mark old settings as transformed
-            s->setValue(QLatin1String("QmlJSTabPreferences/LegacyTransformed"), true);
+
+            // create custom code style out of old settings
+            TextEditor::ICodeStylePreferences *oldCreator = pool->createCodeStyle(
+                     QLatin1String("legacy"), legacyTabSettings,
+                     QVariant(), tr("Old Creator"));
+
+            // change the current delegate and save
+            d->m_globalCodeStyle->setCurrentDelegate(oldCreator);
+            d->m_globalCodeStyle->toSettings(QmlJSTools::Constants::QML_JS_SETTINGS_ID, s);
         }
+        // mark old settings as transformed
+        s->setValue(QLatin1String("QmlJSTabPreferences/LegacyTransformed"), true);
         // legacy handling stop
     }
 
diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp
index 942ad7fb14b..97d6882d2a9 100644
--- a/src/plugins/subversion/subversionplugin.cpp
+++ b/src/plugins/subversion/subversionplugin.cpp
@@ -257,8 +257,7 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e
     if (!Core::ICore::mimeDatabase()->addMimeTypes(QLatin1String(":/trolltech.subversion/Subversion.mimetypes.xml"), errorMessage))
         return false;
 
-    if (QSettings *settings = Core::ICore::settings())
-        m_settings.fromSettings(settings);
+    m_settings.fromSettings(Core::ICore::settings());
 
     addAutoReleasedObject(new SettingsPage);
 
@@ -1180,8 +1179,7 @@ void SubversionPlugin::setSettings(const SubversionSettings &s)
 {
     if (s != m_settings) {
         m_settings = s;
-        if (QSettings *settings = Core::ICore::settings())
-            m_settings.toSettings(settings);
+        m_settings.toSettings(Core::ICore::settings());
         subVersionControl()->emitConfigurationChanged();
     }
 }
diff --git a/src/plugins/texteditor/behaviorsettingspage.cpp b/src/plugins/texteditor/behaviorsettingspage.cpp
index 53b9e37f8ab..752e6d142f6 100644
--- a/src/plugins/texteditor/behaviorsettingspage.cpp
+++ b/src/plugins/texteditor/behaviorsettingspage.cpp
@@ -77,13 +77,12 @@ BehaviorSettingsPage::BehaviorSettingsPagePrivate::BehaviorSettingsPagePrivate
 
 void BehaviorSettingsPage::BehaviorSettingsPagePrivate::init()
 {
-    if (const QSettings *s = Core::ICore::settings()) {
-        m_codeStyle->fromSettings(m_parameters.settingsPrefix, s);
-        m_typingSettings.fromSettings(m_parameters.settingsPrefix, s);
-        m_storageSettings.fromSettings(m_parameters.settingsPrefix, s);
-        m_behaviorSettings.fromSettings(m_parameters.settingsPrefix, s);
-        m_extraEncodingSettings.fromSettings(m_parameters.settingsPrefix, s);
-    }
+    const QSettings *s = Core::ICore::settings();
+    m_codeStyle->fromSettings(m_parameters.settingsPrefix, s);
+    m_typingSettings.fromSettings(m_parameters.settingsPrefix, s);
+    m_storageSettings.fromSettings(m_parameters.settingsPrefix, s);
+    m_behaviorSettings.fromSettings(m_parameters.settingsPrefix, s);
+    m_extraEncodingSettings.fromSettings(m_parameters.settingsPrefix, s);
 }
 
 BehaviorSettingsPage::BehaviorSettingsPage(const BehaviorSettingsPageParameters &p,
diff --git a/src/plugins/texteditor/displaysettingspage.cpp b/src/plugins/texteditor/displaysettingspage.cpp
index 99249edd7ac..12215fecf80 100644
--- a/src/plugins/texteditor/displaysettingspage.cpp
+++ b/src/plugins/texteditor/displaysettingspage.cpp
@@ -53,9 +53,7 @@ DisplaySettingsPage::DisplaySettingsPagePrivate::DisplaySettingsPagePrivate
     (const DisplaySettingsPageParameters &p)
     : m_parameters(p), m_page(0)
 {
-    if (const QSettings *s = Core::ICore::settings()) {
-        m_displaySettings.fromSettings(m_parameters.settingsPrefix, s);
-    }
+    m_displaySettings.fromSettings(m_parameters.settingsPrefix, Core::ICore::settings());
 }
 
 DisplaySettingsPage::DisplaySettingsPage(const DisplaySettingsPageParameters &p,
@@ -153,8 +151,7 @@ void DisplaySettingsPage::setDisplaySettings(const DisplaySettings &newDisplaySe
 {
     if (newDisplaySettings != d->m_displaySettings) {
         d->m_displaySettings = newDisplaySettings;
-        if (QSettings *s = Core::ICore::settings())
-            d->m_displaySettings.toSettings(d->m_parameters.settingsPrefix, s);
+        d->m_displaySettings.toSettings(d->m_parameters.settingsPrefix, Core::ICore::settings());
 
         emit displaySettingsChanged(newDisplaySettings);
     }
diff --git a/src/plugins/texteditor/fontsettingspage.cpp b/src/plugins/texteditor/fontsettingspage.cpp
index 7d0240abb40..2f7da138190 100644
--- a/src/plugins/texteditor/fontsettingspage.cpp
+++ b/src/plugins/texteditor/fontsettingspage.cpp
@@ -623,8 +623,7 @@ void FontSettingsPage::saveSettings()
 {
     if (d_ptr->m_value != d_ptr->m_lastValue) {
         d_ptr->m_lastValue = d_ptr->m_value;
-        if (QSettings *settings = Core::ICore::settings())
-            d_ptr->m_value.toSettings(d_ptr->m_settingsGroup, settings);
+        d_ptr->m_value.toSettings(d_ptr->m_settingsGroup, Core::ICore::settings());
 
         QTimer::singleShot(0, this, SLOT(delayedChange()));
     }
diff --git a/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp b/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp
index e9bcb66eb61..cfcd5ee7cc6 100644
--- a/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp
+++ b/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp
@@ -169,8 +169,7 @@ void HighlighterSettingsPage::settingsFromUI()
     m_d->m_settings.setAlertWhenNoDefinition(m_d->m_page->alertWhenNoDefinition->isChecked());
     m_d->m_settings.setUseFallbackLocation(m_d->m_page->useFallbackLocation->isChecked());
     m_d->m_settings.setIgnoredFilesPatterns(m_d->m_page->ignoreEdit->text());
-    if (QSettings *s = Core::ICore::settings())
-        m_d->m_settings.toSettings(m_d->m_settingsPrefix, s);
+    m_d->m_settings.toSettings(m_d->m_settingsPrefix, Core::ICore::settings());
 }
 
 void HighlighterSettingsPage::settingsToUI()
diff --git a/src/plugins/texteditor/snippets/snippetssettingspage.cpp b/src/plugins/texteditor/snippets/snippetssettingspage.cpp
index 41015a4af15..54d0bb82fb7 100644
--- a/src/plugins/texteditor/snippets/snippetssettingspage.cpp
+++ b/src/plugins/texteditor/snippets/snippetssettingspage.cpp
@@ -419,15 +419,13 @@ void SnippetsSettingsPagePrivate::loadSettings()
     if (m_ui.groupCombo->count() == 0)
         return;
 
-    if (QSettings *s = Core::ICore::settings()) {
-        m_settings.fromSettings(m_settingsPrefix, s);
-        const QString &lastGroupName = m_settings.lastUsedSnippetGroup();
-        const int index = m_ui.groupCombo->findText(lastGroupName);
-        if (index != -1)
-            m_ui.groupCombo->setCurrentIndex(index);
-        else
-            m_ui.groupCombo->setCurrentIndex(0);
-    }
+    m_settings.fromSettings(m_settingsPrefix, Core::ICore::settings());
+    const QString &lastGroupName = m_settings.lastUsedSnippetGroup();
+    const int index = m_ui.groupCombo->findText(lastGroupName);
+    if (index != -1)
+        m_ui.groupCombo->setCurrentIndex(index);
+    else
+        m_ui.groupCombo->setCurrentIndex(0);
 }
 
 void SnippetsSettingsPagePrivate::writeSettings()
@@ -435,10 +433,8 @@ void SnippetsSettingsPagePrivate::writeSettings()
     if (m_ui.groupCombo->count() == 0)
         return;
 
-    if (QSettings *s = Core::ICore::settings()) {
-        m_settings.setLastUsedSnippetGroup(m_ui.groupCombo->currentText());
-        m_settings.toSettings(m_settingsPrefix, s);
-    }
+    m_settings.setLastUsedSnippetGroup(m_ui.groupCombo->currentText());
+    m_settings.toSettings(m_settingsPrefix, Core::ICore::settings());
 }
 
 bool SnippetsSettingsPagePrivate::settingsChanged() const
diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp
index 5db1a1ea2bc..5114e6e06f2 100644
--- a/src/plugins/texteditor/texteditorsettings.cpp
+++ b/src/plugins/texteditor/texteditorsettings.cpp
@@ -229,8 +229,7 @@ TextEditorSettings::TextEditorSettings(QObject *parent)
             this, SIGNAL(displaySettingsChanged(TextEditor::DisplaySettings)));
 
     // TODO: Move these settings to TextEditor category
-    if (QSettings *s = Core::ICore::settings())
-        m_d->m_completionSettings.fromSettings(QLatin1String("CppTools/"), s);
+    m_d->m_completionSettings.fromSettings(QLatin1String("CppTools/"), Core::ICore::settings());
 }
 
 TextEditorSettings::~TextEditorSettings()
@@ -336,8 +335,7 @@ void TextEditorSettings::setCompletionSettings(const TextEditor::CompletionSetti
         return;
 
     m_d->m_completionSettings = settings;
-    if (QSettings *s = Core::ICore::settings())
-        m_d->m_completionSettings.toSettings(QLatin1String("CppTools/"), s);
+    m_d->m_completionSettings.toSettings(QLatin1String("CppTools/"), Core::ICore::settings());
 
     emit completionSettingsChanged(m_d->m_completionSettings);
 }
-- 
GitLab