summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cpptoolssettings.cpp
diff options
context:
space:
mode:
authorOrgad Shaneh <orgads@gmail.com>2012-08-09 12:58:51 +0300
committerhjk <qthjk@ovi.com>2012-08-09 13:09:08 +0200
commit99aa8007c17abdd1a89dffc82a29dbf7b46f190e (patch)
tree195f7c5af77e3987c1b75f002b21a8ba35bd4b76 /src/plugins/cpptools/cpptoolssettings.cpp
parent7ba9c60f5530a4289f7e544a25e53c6d89c73a3a (diff)
downloadqt-creator-99aa8007c17abdd1a89dffc82a29dbf7b46f190e.tar.gz
Remove NULL tests for Core::ICore::settings()
It cannot really be NULL Change-Id: I7231e00754464347dc5750249f751cda7f831930 Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'src/plugins/cpptools/cpptoolssettings.cpp')
-rw-r--r--src/plugins/cpptools/cpptoolssettings.cpp93
1 files changed, 46 insertions, 47 deletions
diff --git a/src/plugins/cpptools/cpptoolssettings.cpp b/src/plugins/cpptools/cpptoolssettings.cpp
index 547d31e056..31e611eb4d 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
}