diff options
author | Ivan Komissarov <abbapoh@gmail.com> | 2021-10-25 14:29:15 +0300 |
---|---|---|
committer | Ivan Komissarov <ABBAPOH@gmail.com> | 2021-10-26 12:38:04 +0000 |
commit | b035d081fed2cb5c1a90cd609011955a1d587472 (patch) | |
tree | 62997ce97b9f17f4184d66236a058c6bce451104 | |
parent | 22b93598471a22e09052405ad33e24bd15f1e6be (diff) | |
download | qbs-b035d081fed2cb5c1a90cd609011955a1d587472.tar.gz |
Do not migrate profiles dir in Settings anymore
It was only used by Qt and is not needed because of providers these
days.
Task-number: QTCREATORBUG-26475
Change-Id: I8bf79bcaa7468c8df3669902ac453d46bbfa46f8
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r-- | src/lib/corelib/tools/settingscreator.cpp | 31 | ||||
-rw-r--r-- | tests/auto/tools/tst_tools.cpp | 6 |
2 files changed, 3 insertions, 34 deletions
diff --git a/src/lib/corelib/tools/settingscreator.cpp b/src/lib/corelib/tools/settingscreator.cpp index 3fdaf0bc3..455e35b34 100644 --- a/src/lib/corelib/tools/settingscreator.cpp +++ b/src/lib/corelib/tools/settingscreator.cpp @@ -84,16 +84,6 @@ void SettingsCreator::migrate() QString oldSettingsDir = m_settingsBaseDir; if (thePredecessor.isValid()) oldSettingsDir.append(QLatin1String("/qbs/")).append(thePredecessor.toString()); - QString oldProfilesDir = oldSettingsDir; - if (!thePredecessor.isValid()) - oldProfilesDir += QLatin1String("/qbs"); - oldProfilesDir += QLatin1String("/profiles"); - const QString newProfilesDir = m_newSettingsDir + QLatin1String("/profiles"); - QString errorMessage; - if (QFileInfo(oldProfilesDir).exists() - && !copyFileRecursion(oldProfilesDir, newProfilesDir, false, true, &errorMessage)) { - qWarning() << "Error in settings migration: " << errorMessage; - } const QString oldSettingsFilePath = oldSettingsDir + QLatin1Char('/') + m_settingsFileName; if (QFileInfo(oldSettingsFilePath).exists() && (!QDir::root().mkpath(m_newSettingsDir) @@ -102,28 +92,7 @@ void SettingsCreator::migrate() << "to" << m_newSettingsFilePath; } - // Adapt all paths in settings that point to the old location. At the time of this writing, - // that's only preferences.qbsSearchPaths as written by libqtprofilesetup, but we don't want - // to hardcode that here. m_settings = std::make_unique<QSettings>(m_newSettingsFilePath, format()); - const auto allKeys = m_settings->allKeys(); - for (const QString &key : allKeys) { - QVariant v = m_settings->value(key); - if (v.userType() == QMetaType::QString) { - QString s = v.toString(); - if (s.contains(oldProfilesDir)) - m_settings->setValue(key, s.replace(oldProfilesDir, newProfilesDir)); - } else if (v.userType() == QMetaType::QStringList) { - const QStringList oldList = v.toStringList(); - QStringList newList; - for (const QString &oldString : oldList) { - QString newString = oldString; - newList << newString.replace(oldProfilesDir, newProfilesDir); - } - if (newList != oldList) - m_settings->setValue(key, newList); - } - } } void SettingsCreator::createQSettings() diff --git a/tests/auto/tools/tst_tools.cpp b/tests/auto/tools/tst_tools.cpp index 894cfdcf6..a872bdd0d 100644 --- a/tests/auto/tools/tst_tools.cpp +++ b/tests/auto/tools/tst_tools.cpp @@ -308,10 +308,10 @@ void TestTools::testSettingsMigration() QFETCH(bool, hasOldSettings); Settings settings(baseDir); if (hasOldSettings) { - QVERIFY(QFileInfo(settings.baseDirectory() + "/qbs/" QBS_VERSION "/profiles/right.txt") + // checks that we do not copy old "profiles/" dir anymore + QVERIFY(!QFileInfo(settings.baseDirectory() + "/qbs/" QBS_VERSION "/profiles/right.txt") .exists()); - QCOMPARE(settings.value("key", Settings::UserScope).toString(), - settings.baseDirectory() + "/qbs/" QBS_VERSION "/profilesright"); + QVERIFY(!settings.value("key", Settings::UserScope).toString().isEmpty()); } else { QVERIFY(!QFileInfo(settings.baseDirectory() + "/qbs/" QBS_VERSION "/profiles").exists()); QVERIFY(settings.allKeys(Settings::UserScope).empty()); |