From b035d081fed2cb5c1a90cd609011955a1d587472 Mon Sep 17 00:00:00 2001 From: Ivan Komissarov Date: Mon, 25 Oct 2021 14:29:15 +0300 Subject: 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 --- src/lib/corelib/tools/settingscreator.cpp | 31 ------------------------------- 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(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()); -- cgit v1.2.1