From d6fe357d81da96475c02eb3c73f660d8121381e4 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 5 Sep 2023 15:25:26 +0200 Subject: Utils: Use a proper class as Key The Key encapsulates now a QByteArray. Plan is to use QByteArray::fromRawData on literals, but that's not active yet due to an unclear ASAN report, see the gerrit discussion. For now we also paddle back when interfacing QSettings, instead of mimicing writing a QVariantMap (and fail in some corners), always convert the Store. This is meant to go away in the future when code paths are better controled. Change-Id: Id1206a434d511f8003903d5322c7c9bd5f5fb859 Reviewed-by: Reviewed-by: Marcus Tillmanns --- src/libs/utils/aspects.cpp | 2 +- src/libs/utils/persistentsettings.cpp | 65 ++++++------- src/libs/utils/persistentsettings.h | 2 +- src/libs/utils/qtcsettings.cpp | 11 +++ src/libs/utils/qtcsettings.h | 8 +- src/libs/utils/store.cpp | 108 ++++++++++++++------- src/libs/utils/store.h | 5 + src/libs/utils/storekey.h | 52 +++++++++- src/libs/utils/unixutils.cpp | 2 +- .../baremetal/debugserverprovidermanager.cpp | 4 +- src/plugins/clangformat/clangformatsettings.cpp | 4 +- .../classview/classviewnavigationwidgetfactory.cpp | 1 + src/plugins/coreplugin/coreplugin.cpp | 1 + src/plugins/coreplugin/find/findplugin.cpp | 18 ++-- src/plugins/coreplugin/foldernavigationwidget.cpp | 1 + src/plugins/coreplugin/icore.cpp | 4 +- src/plugins/coreplugin/session.cpp | 2 +- src/plugins/cppeditor/cppcodemodelsettings.cpp | 8 +- src/plugins/debugger/debuggeractions.cpp | 6 +- src/plugins/designer/settingsmanager.cpp | 6 +- src/plugins/fakevim/fakevimactions.cpp | 8 +- src/plugins/fakevim/fakevimactions.h | 10 +- src/plugins/fakevim/fakevimhandler.cpp | 8 +- .../languageclient/languageclientsettings.cpp | 4 +- .../languageclient/languageclientsettings.h | 4 +- src/plugins/mcusupport/test/unittest.cpp | 19 ++-- src/plugins/perfprofiler/perfsettings.cpp | 12 +-- .../customwizard/customwizardpage.cpp | 4 +- .../projectexplorer/editorconfiguration.cpp | 4 +- src/plugins/projectexplorer/extraabi.cpp | 8 +- src/plugins/projectexplorer/userfileaccessor.cpp | 3 +- .../qmakeprojectmanager/wizards/qtwizard.cpp | 2 +- src/plugins/qtsupport/baseqtversion.cpp | 6 +- src/plugins/qtsupport/qtversionmanager.cpp | 12 +-- 34 files changed, 255 insertions(+), 159 deletions(-) diff --git a/src/libs/utils/aspects.cpp b/src/libs/utils/aspects.cpp index 04cf8b786d..bcd424bd62 100644 --- a/src/libs/utils/aspects.cpp +++ b/src/libs/utils/aspects.cpp @@ -2996,7 +2996,7 @@ SettingsGroupNester::SettingsGroupNester(const QStringList &groups) { QTC_ASSERT(theSettings, return); for (const QString &group : groups) - theSettings->beginGroup(group); + theSettings->beginGroup(keyFromString(group)); } SettingsGroupNester::~SettingsGroupNester() diff --git a/src/libs/utils/persistentsettings.cpp b/src/libs/utils/persistentsettings.cpp index 97c0fb9e94..54a829004b 100644 --- a/src/libs/utils/persistentsettings.cpp +++ b/src/libs/utils/persistentsettings.cpp @@ -106,20 +106,20 @@ const QString keyAttribute("key"); struct ParseValueStackEntry { - explicit ParseValueStackEntry(QVariant::Type t = QVariant::Invalid, const Key &k = {}) : type(t), key(k) {} - explicit ParseValueStackEntry(const QVariant &aSimpleValue, const Key &k); + explicit ParseValueStackEntry(QVariant::Type t = QVariant::Invalid, const QString &k = {}) : type(t), key(k) {} + explicit ParseValueStackEntry(const QVariant &aSimpleValue, const QString &k); QVariant value() const; - void addChild(const Key &key, const QVariant &v); + void addChild(const QString &key, const QVariant &v); QVariant::Type type; - Key key; + QString key; QVariant simpleValue; QVariantList listValue; - Store mapValue; + QVariantMap mapValue; }; -ParseValueStackEntry::ParseValueStackEntry(const QVariant &aSimpleValue, const Key &k) +ParseValueStackEntry::ParseValueStackEntry(const QVariant &aSimpleValue, const QString &k) : type(aSimpleValue.type()), key(k), simpleValue(aSimpleValue) { QTC_ASSERT(simpleValue.isValid(), return); @@ -131,7 +131,7 @@ QVariant ParseValueStackEntry::value() const case QVariant::Invalid: return QVariant(); case QVariant::Map: - return variantFromStore(mapValue); + return QVariant(mapValue); case QVariant::List: return QVariant(listValue); default: @@ -140,7 +140,7 @@ QVariant ParseValueStackEntry::value() const return simpleValue; } -void ParseValueStackEntry::addChild(const Key &key, const QVariant &v) +void ParseValueStackEntry::addChild(const QString &key, const QVariant &v) { switch (type) { case QVariant::Map: @@ -159,7 +159,7 @@ void ParseValueStackEntry::addChild(const Key &key, const QVariant &v) class ParseContext { public: - Store parse(const FilePath &file); + QVariantMap parse(const FilePath &file); private: QVariant readSimpleValue(QXmlStreamReader &r, const QXmlStreamAttributes &attributes) const; @@ -170,11 +170,11 @@ private: static QString formatWarning(const QXmlStreamReader &r, const QString &message); QStack m_valueStack; - Store m_result; - Key m_currentVariableName; + QVariantMap m_result; + QString m_currentVariableName; }; -Store ParseContext::parse(const FilePath &file) +QVariantMap ParseContext::parse(const FilePath &file) { QXmlStreamReader r(file.fileContents().value_or(QByteArray())); @@ -194,7 +194,7 @@ Store ParseContext::parse(const FilePath &file) case QXmlStreamReader::Invalid: qWarning("Error reading %s:%d: %s", qPrintable(file.fileName()), int(r.lineNumber()), qPrintable(r.errorString())); - return Store(); + return {}; default: break; } // switch token @@ -206,13 +206,13 @@ bool ParseContext::handleStartElement(QXmlStreamReader &r) { const QStringView name = r.name(); if (name == variableElement) { - m_currentVariableName = keyFromString(r.readElementText()); + m_currentVariableName = r.readElementText(); return false; } if (name == valueElement) { const QXmlStreamAttributes attributes = r.attributes(); - const Key key = attributes.hasAttribute(keyAttribute) ? - keyFromString(attributes.value(keyAttribute).toString()) : Key(); + const QString key = attributes.hasAttribute(keyAttribute) ? + attributes.value(keyAttribute).toString() : QString(); // This reads away the end element, so, handle end element right here. const QVariant v = readSimpleValue(r, attributes); if (!v.isValid()) { @@ -224,15 +224,15 @@ bool ParseContext::handleStartElement(QXmlStreamReader &r) } if (name == valueListElement) { const QXmlStreamAttributes attributes = r.attributes(); - const Key key = attributes.hasAttribute(keyAttribute) ? - keyFromString(attributes.value(keyAttribute).toString()) : Key(); + const QString key = attributes.hasAttribute(keyAttribute) ? + attributes.value(keyAttribute).toString() : QString(); m_valueStack.push_back(ParseValueStackEntry(QVariant::List, key)); return false; } if (name == valueMapElement) { const QXmlStreamAttributes attributes = r.attributes(); - const Key key = attributes.hasAttribute(keyAttribute) ? - keyFromString(attributes.value(keyAttribute).toString()) : Key(); + const QString key = attributes.hasAttribute(keyAttribute) ? + attributes.value(keyAttribute).toString() : QString(); m_valueStack.push_back(ParseValueStackEntry(QVariant::Map, key)); return false; } @@ -293,14 +293,14 @@ PersistentSettingsReader::PersistentSettingsReader() = default; QVariant PersistentSettingsReader::restoreValue(const Key &variable, const QVariant &defaultValue) const { - if (m_valueMap.contains(variable)) - return m_valueMap.value(variable); + if (m_valueMap.contains(stringFromKey(variable))) + return m_valueMap.value(stringFromKey(variable)); return defaultValue; } Store PersistentSettingsReader::restoreValues() const { - return m_valueMap; + return storeFromMap(m_valueMap); } bool PersistentSettingsReader::load(const FilePath &fileName) @@ -331,12 +331,12 @@ FilePath PersistentSettingsReader::filePath() */ #if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) -static QString xmlAttrFromKey(const Key &key) { return stringFromKey(key); } +static QString xmlAttrFromKey(const QString &key) { return key; } #else -static Key xmlAttrFromKey(const Key &key) { return key; } +static QString xmlAttrFromKey(const QString &key) { return key; } #endif -static void writeVariantValue(QXmlStreamWriter &w, const QVariant &variant, const Key &key = {}) +static void writeVariantValue(QXmlStreamWriter &w, const QVariant &variant, const QString &key = {}) { static const int storeId = qMetaTypeId(); @@ -355,9 +355,9 @@ static void writeVariantValue(QXmlStreamWriter &w, const QVariant &variant, cons w.writeAttribute(typeAttribute, "QVariantMap"); if (!key.isEmpty()) w.writeAttribute(keyAttribute, xmlAttrFromKey(key)); - const Store varMap = storeFromVariant(variant); - const Store::const_iterator cend = varMap.constEnd(); - for (Store::const_iterator i = varMap.constBegin(); i != cend; ++i) + const QVariantMap varMap = variant.toMap(); + const auto cend = varMap.constEnd(); + for (auto i = varMap.constBegin(); i != cend; ++i) writeVariantValue(w, i.value(), i.key()); w.writeEndElement(); } else if (variantType == QMetaType::QObjectStar) { @@ -427,11 +427,10 @@ bool PersistentSettingsWriter::write(const Store &data, QString *errorString) co QCoreApplication::applicationVersion(), QDateTime::currentDateTime().toString(Qt::ISODate))); w.writeStartElement(qtCreatorElement); - const Store::const_iterator cend = data.constEnd(); - for (Store::const_iterator it = data.constBegin(); it != cend; ++it) { + const QVariantMap map = mapFromStore(data); + for (auto it = map.constBegin(), cend = map.constEnd(); it != cend; ++it) { w.writeStartElement(dataElement); - // FIXME: stringFromKey() not needed from Qt 6.5 onward. - w.writeTextElement(variableElement, stringFromKey(it.key())); + w.writeTextElement(variableElement, it.key()); writeVariantValue(w, it.value()); w.writeEndElement(); } diff --git a/src/libs/utils/persistentsettings.h b/src/libs/utils/persistentsettings.h index 4997433ef6..8092e8a011 100644 --- a/src/libs/utils/persistentsettings.h +++ b/src/libs/utils/persistentsettings.h @@ -26,7 +26,7 @@ public: FilePath filePath(); private: - Store m_valueMap; + QVariantMap m_valueMap; FilePath m_filePath; }; diff --git a/src/libs/utils/qtcsettings.cpp b/src/libs/utils/qtcsettings.cpp index 65e73615e2..921e47946c 100644 --- a/src/libs/utils/qtcsettings.cpp +++ b/src/libs/utils/qtcsettings.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "qtcsettings.h" +#include "store.h" namespace Utils { @@ -29,4 +30,14 @@ namespace Utils { \sa QSettings::setValue() */ +QVariant QtcSettings::value(const Key &key, const QVariant &def) const +{ + return QSettings::value(stringFromKey(key), def); +} + +void QtcSettings::setValue(const Key &key, const QVariant &value) +{ + QSettings::setValue(stringFromKey(key), mapEntryFromStoreEntry(value)); +} + } // namespace Utils diff --git a/src/libs/utils/qtcsettings.h b/src/libs/utils/qtcsettings.h index e4fd76d839..3d670cf605 100644 --- a/src/libs/utils/qtcsettings.h +++ b/src/libs/utils/qtcsettings.h @@ -5,7 +5,7 @@ #include "utils_global.h" -#include "store.h" +#include "storekey.h" #include @@ -17,12 +17,10 @@ public: using QSettings::QSettings; void beginGroup(const Key &prefix) { QSettings::beginGroup(stringFromKey(prefix)); } - void beginGroup(const QString &prefix) { QSettings::beginGroup(prefix); } - void beginGroup(const char *prefix) { QSettings::beginGroup(stringFromKey(prefix)); } QVariant value(const Key &key) const { return QSettings::value(stringFromKey(key)); } - QVariant value(const Key &key, const QVariant &def) const { return QSettings::value(stringFromKey(key), def); } - void setValue(const Key &key, const QVariant &value) { QSettings::setValue(stringFromKey(key), value); } + QVariant value(const Key &key, const QVariant &def) const; + void setValue(const Key &key, const QVariant &value); void remove(const Key &key) { QSettings::remove(stringFromKey(key)); } bool contains(const Key &key) const { return QSettings::contains(stringFromKey(key)); } diff --git a/src/libs/utils/store.cpp b/src/libs/utils/store.cpp index 4047aced9f..8ca42a5560 100644 --- a/src/libs/utils/store.cpp +++ b/src/libs/utils/store.cpp @@ -42,18 +42,37 @@ Store storeFromVariant(const QVariant &value) return Store(); } +static QVariantList storeListFromMapList(const QVariantList &mapList); +static QVariantList mapListFromStoreList(const QVariantList &storeList); + +QVariant storeEntryFromMapEntry(const QVariant &mapEntry) +{ + if (mapEntry.type() == QVariant::Map) + return QVariant::fromValue(storeFromMap(mapEntry.toMap())); + + if (mapEntry.type() == QVariant::List) + return QVariant::fromValue(storeListFromMapList(mapEntry.toList())); + + return mapEntry; +} + +QVariant mapEntryFromStoreEntry(const QVariant &storeEntry) +{ + if (storeEntry.metaType() == QMetaType::fromType()) + return QVariant::fromValue(mapFromStore(storeEntry.value())); + + if (storeEntry.type() == QVariant::List) + return QVariant::fromValue(mapListFromStoreList(storeEntry.toList())); + + return storeEntry; +} + static QVariantList storeListFromMapList(const QVariantList &mapList) { QVariantList storeList; - for (const auto &mapEntry : mapList) { - if (mapEntry.type() == QVariant::Map) - storeList.append(QVariant::fromValue(storeFromMap(mapEntry.toMap()))); - else if (mapEntry.type() == QVariant::List) - storeList.append(QVariant::fromValue(storeListFromMapList(mapEntry.toList()))); - else - storeList.append(mapEntry); - } + for (const auto &mapEntry : mapList) + storeList.append(storeEntryFromMapEntry(mapEntry)); return storeList; } @@ -62,14 +81,8 @@ static QVariantList mapListFromStoreList(const QVariantList &storeList) { QVariantList mapList; - for (const auto &storeEntry : storeList) { - if (storeEntry.metaType() == QMetaType::fromType()) - mapList.append(QVariant::fromValue(mapFromStore(storeEntry.value()))); - else if (storeEntry.type() == QVariant::List) - mapList.append(QVariant::fromValue(mapListFromStoreList(storeEntry.toList()))); - else - mapList.append(storeEntry); - } + for (const QVariant &storeEntry : storeList) + mapList.append(mapEntryFromStoreEntry(storeEntry)); return mapList; } @@ -77,30 +90,20 @@ static QVariantList mapListFromStoreList(const QVariantList &storeList) Store storeFromMap(const QVariantMap &map) { Store store; - for (auto it = map.begin(); it != map.end(); ++it) { - if (it.value().type() == QVariant::Map) { - store.insert(keyFromString(it.key()), QVariant::fromValue(storeFromMap(it->toMap()))); - } else if (it.value().type() == QVariant::List) { - store.insert(keyFromString(it.key()), - QVariant::fromValue(storeListFromMapList(it->toList()))); - } else { - store.insert(keyFromString(it.key()), it.value()); - } - } + + for (auto it = map.begin(); it != map.end(); ++it) + store.insert(keyFromString(it.key()), storeEntryFromMapEntry(it.value())); + return store; } QVariantMap mapFromStore(const Store &store) { QVariantMap map; - for (auto it = store.begin(); it != store.end(); ++it) { - if (it.value().metaType() == QMetaType::fromType()) - map.insert(stringFromKey(it.key()), mapFromStore(it->value())); - else if (it.value().type() == QVariant::List) - map.insert(stringFromKey(it.key()), mapListFromStoreList(it->toList())); - else - map.insert(stringFromKey(it.key()), it.value()); - } + + for (auto it = store.begin(); it != store.end(); ++it) + map.insert(stringFromKey(it.key()), mapEntryFromStoreEntry(it.value())); + return map; } @@ -110,9 +113,40 @@ bool isStore(const QVariant &value) return typeId == QMetaType::QVariantMap || typeId == qMetaTypeId(); } +Key::Key(const char *key, size_t n) + : data(QByteArray::fromRawData(key, n)) +{} + +Key::Key(const Key &base, int number) + : data(base.data + QByteArray::number(number)) +{} + +Key::~Key() +{} + +const QByteArrayView Key::view() const +{ + return data; +} + +const QByteArray &Key::toByteArray() const +{ + return data; +} + Key numberedKey(const Key &key, int number) { - return key + Key::number(number); + return Key(key, number); +} + +Key keyFromString(const QString &str) +{ + return str.toUtf8(); +} + +QString stringFromKey(const Key &key) +{ + return QString::fromLatin1(key.view()); } expected_str storeFromJson(const QByteArray &json) @@ -140,7 +174,7 @@ Store storeFromSettings(const Key &groupKey, QtcSettings *s) s->beginGroup(groupKey); const KeyList keys = keysFromStrings(s->allKeys()); for (const Key &key : keys) - store.insert(key, s->value(key)); + store.insert(key, storeEntryFromMapEntry(s->value(key))); s->endGroup(); return store; } @@ -149,7 +183,7 @@ void storeToSettings(const Key &groupKey, QtcSettings *s, const Store &store) { s->beginGroup(groupKey); for (auto it = store.constBegin(), end = store.constEnd(); it != end; ++it) - s->setValue(it.key(), it.value()); + s->setValue(it.key(), mapEntryFromStoreEntry(it.value())); s->endGroup(); } diff --git a/src/libs/utils/store.h b/src/libs/utils/store.h index 196f9777e4..df45cc8e9c 100644 --- a/src/libs/utils/store.h +++ b/src/libs/utils/store.h @@ -16,6 +16,7 @@ class QtcSettings; using KeyList = QList; using Store = QMap; +using OldStore = QMap; QTCREATOR_UTILS_EXPORT KeyList keysFromStrings(const QStringList &list); QTCREATOR_UTILS_EXPORT QStringList stringsFromKeys(const KeyList &list); @@ -33,6 +34,9 @@ QTCREATOR_UTILS_EXPORT Key numberedKey(const Key &key, int number); QTCREATOR_UTILS_EXPORT expected_str storeFromJson(const QByteArray &json); QTCREATOR_UTILS_EXPORT QByteArray jsonFromStore(const Store &store); +// These recursively change type. +QTCREATOR_UTILS_EXPORT QVariant storeEntryFromMapEntry(const QVariant &value); +QTCREATOR_UTILS_EXPORT QVariant mapEntryFromStoreEntry(const QVariant &value); // Don't use in new code. QTCREATOR_UTILS_EXPORT Store storeFromSettings(const Key &groupKey, QtcSettings *s); @@ -41,3 +45,4 @@ QTCREATOR_UTILS_EXPORT void storeToSettings(const Key &groupKey, QtcSettings *s, } // Utils Q_DECLARE_METATYPE(Utils::Store) +Q_DECLARE_METATYPE(Utils::OldStore) diff --git a/src/libs/utils/storekey.h b/src/libs/utils/storekey.h index 7e02353e17..79e4360915 100644 --- a/src/libs/utils/storekey.h +++ b/src/libs/utils/storekey.h @@ -5,13 +5,59 @@ #include "utils_global.h" +#include #include +#include namespace Utils { -using Key = QByteArray; +class QTCREATOR_UTILS_EXPORT Key +{ +public: + Key() = default; + Key(const QByteArray &key) : data(key) {} -inline Key keyFromString(const QString &str) { return str.toUtf8(); } -inline QString stringFromKey(const Key &key) { return QString::fromUtf8(key); } + template + Key(const char (&key)[N]) : data(key) {} + + // FIXME: + // The following is wanted, but not used yet due to unclear ASAN report. + // template + // Key(const char (&key)[N]) : Key(key, strlen(key)) {} + + Key(const char *key, size_t n); + + Key(const Key &base, int number); + ~Key(); + + const QByteArrayView view() const; + const QByteArray &toByteArray() const; + QByteArrayView operator()() const { return data; } + + bool isEmpty() const { return data.isEmpty(); } + void clear() { data.clear(); } + + friend bool operator<(const Key &a, const Key &b) { return a.data < b.data; } + friend bool operator==(const Key &a, const Key &b) { return a.data == b.data; } + + friend Key operator+(const Key &a, const Key &b) + { + return Key(a.data + b.data); + } + friend Key operator+(const Key &a, char b) + { + return Key(a.data + b); + } + friend size_t qHash(const Key &key, size_t seed = 0) + { + return qHash(key.data, seed); + } + +private: + QByteArray data; +}; + +QTCREATOR_UTILS_EXPORT Key keyFromString(const QString &str); +QTCREATOR_UTILS_EXPORT QString stringFromKey(const Key &key); } // Utils diff --git a/src/libs/utils/unixutils.cpp b/src/libs/utils/unixutils.cpp index 5d626c74f2..c275d2c303 100644 --- a/src/libs/utils/unixutils.cpp +++ b/src/libs/utils/unixutils.cpp @@ -27,7 +27,7 @@ QString UnixUtils::fileBrowser(const QSettings *settings) void UnixUtils::setFileBrowser(QSettings *settings, const QString &term) { - QtcSettings::setValueWithDefault(settings, "General/FileBrowser", term, defaultFileBrowser()); + QtcSettings::setValueWithDefault(settings, Key("General/FileBrowser"), term, defaultFileBrowser()); } diff --git a/src/plugins/baremetal/debugserverprovidermanager.cpp b/src/plugins/baremetal/debugserverprovidermanager.cpp index 536b279700..7716c200c0 100644 --- a/src/plugins/baremetal/debugserverprovidermanager.cpp +++ b/src/plugins/baremetal/debugserverprovidermanager.cpp @@ -97,9 +97,9 @@ void DebugServerProviderManager::restoreProviders() Store map = storeFromVariant(data.value(key)); const KeyList keys = map.keys(); for (const Key &key : keys) { - const int lastDot = key.lastIndexOf('.'); + const int lastDot = key.view().lastIndexOf('.'); if (lastDot != -1) - map[key.mid(lastDot + 1)] = map[key]; + map[key.view().mid(lastDot + 1).toByteArray()] = map[key]; } bool restored = false; for (IDebugServerProviderFactory *f : std::as_const(m_factories)) { diff --git a/src/plugins/clangformat/clangformatsettings.cpp b/src/plugins/clangformat/clangformatsettings.cpp index f6be8e922a..daefd3f88b 100644 --- a/src/plugins/clangformat/clangformatsettings.cpp +++ b/src/plugins/clangformat/clangformatsettings.cpp @@ -21,7 +21,7 @@ ClangFormatSettings &ClangFormatSettings::instance() ClangFormatSettings::ClangFormatSettings() { QtcSettings *settings = Core::ICore::settings(); - settings->beginGroup(QLatin1String(Constants::SETTINGS_ID)); + settings->beginGroup(Constants::SETTINGS_ID); m_overrideDefaultFile = settings->value(Constants::OVERRIDE_FILE_ID, false).toBool(); m_formatWhileTyping = settings->value(Constants::FORMAT_WHILE_TYPING_ID, false).toBool(); m_formatOnSave = settings->value(Constants::FORMAT_CODE_ON_SAVE_ID, false).toBool(); @@ -45,7 +45,7 @@ ClangFormatSettings::ClangFormatSettings() void ClangFormatSettings::write() const { QtcSettings *settings = Core::ICore::settings(); - settings->beginGroup(QLatin1String(Constants::SETTINGS_ID)); + settings->beginGroup(Constants::SETTINGS_ID); settings->setValue(Constants::OVERRIDE_FILE_ID, m_overrideDefaultFile); settings->setValue(Constants::FORMAT_WHILE_TYPING_ID, m_formatWhileTyping); settings->setValue(Constants::FORMAT_CODE_ON_SAVE_ID, m_formatOnSave); diff --git a/src/plugins/classview/classviewnavigationwidgetfactory.cpp b/src/plugins/classview/classviewnavigationwidgetfactory.cpp index 91612317be..aa1429fc4b 100644 --- a/src/plugins/classview/classviewnavigationwidgetfactory.cpp +++ b/src/plugins/classview/classviewnavigationwidgetfactory.cpp @@ -8,6 +8,7 @@ #include #include +#include using namespace Utils; diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index d1265d18ef..9dbd1980b9 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -81,6 +81,7 @@ CorePlugin::CorePlugin() qRegisterMetaType(); qRegisterMetaType(); qRegisterMetaType(); + qRegisterMetaType(); m_instance = this; setupSystemEnvironment(); } diff --git a/src/plugins/coreplugin/find/findplugin.cpp b/src/plugins/coreplugin/find/findplugin.cpp index 5cf8eedd2e..6836b70e07 100644 --- a/src/plugins/coreplugin/find/findplugin.cpp +++ b/src/plugins/coreplugin/find/findplugin.cpp @@ -371,7 +371,7 @@ bool Find::hasFindFlag(FindFlag flag) void FindPrivate::writeSettings() { QtcSettings *settings = ICore::settings(); - settings->beginGroup(QLatin1String("Find")); + settings->beginGroup("Find"); settings->setValueWithDefault("Backward", bool(m_findFlags & FindBackward), false); settings->setValueWithDefault("CaseSensitively", bool(m_findFlags & FindCaseSensitively), false); settings->setValueWithDefault("WholeWords", bool(m_findFlags & FindWholeWords), false); @@ -389,18 +389,18 @@ void FindPrivate::writeSettings() void FindPrivate::readSettings() { - QSettings *settings = ICore::settings(); - settings->beginGroup(QLatin1String("Find")); + QtcSettings *settings = ICore::settings(); + settings->beginGroup("Find"); { QSignalBlocker blocker(m_instance); - Find::setBackward(settings->value(QLatin1String("Backward"), false).toBool()); - Find::setCaseSensitive(settings->value(QLatin1String("CaseSensitively"), false).toBool()); - Find::setWholeWord(settings->value(QLatin1String("WholeWords"), false).toBool()); - Find::setRegularExpression(settings->value(QLatin1String("RegularExpression"), false).toBool()); - Find::setPreserveCase(settings->value(QLatin1String("PreserveCase"), false).toBool()); + Find::setBackward(settings->value("Backward", false).toBool()); + Find::setCaseSensitive(settings->value("CaseSensitively", false).toBool()); + Find::setWholeWord(settings->value("WholeWords", false).toBool()); + Find::setRegularExpression(settings->value("RegularExpression", false).toBool()); + Find::setPreserveCase(settings->value("PreserveCase", false).toBool()); } m_findCompletionModel.readSettings(settings); - m_replaceCompletions = settings->value(QLatin1String("ReplaceStrings")).toStringList(); + m_replaceCompletions = settings->value("ReplaceStrings").toStringList(); m_replaceCompletionModel.setStringList(m_replaceCompletions); settings->endGroup(); m_findToolBar->readSettings(); diff --git a/src/plugins/coreplugin/foldernavigationwidget.cpp b/src/plugins/coreplugin/foldernavigationwidget.cpp index 82101df813..b58b6c4e46 100644 --- a/src/plugins/coreplugin/foldernavigationwidget.cpp +++ b/src/plugins/coreplugin/foldernavigationwidget.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index a4cad44e70..570dbc5d8d 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -2233,7 +2233,7 @@ void MainWindow::aboutToShutdown() void MainWindowPrivate::readSettings() { QtcSettings *settings = PluginManager::settings(); - settings->beginGroup(QLatin1String(settingsGroup)); + settings->beginGroup(settingsGroup); if (m_overrideColor.isValid()) { StyleHelper::setBaseColor(m_overrideColor); @@ -2278,7 +2278,7 @@ void MainWindowPrivate::readSettings() void MainWindow::saveSettings() { QtcSettings *settings = PluginManager::settings(); - settings->beginGroup(QLatin1String(settingsGroup)); + settings->beginGroup(settingsGroup); if (!(d->m_overrideColor.isValid() && StyleHelper::baseColor() == d->m_overrideColor)) settings->setValueWithDefault(colorKey, diff --git a/src/plugins/coreplugin/session.cpp b/src/plugins/coreplugin/session.cpp index 13d3902d96..106558c14b 100644 --- a/src/plugins/coreplugin/session.cpp +++ b/src/plugins/coreplugin/session.cpp @@ -541,7 +541,7 @@ void SessionManagerPrivate::restoreSessionValues(const PersistentSettingsReader // restore toplevel items that are not restored by restoreValues const auto end = values.constEnd(); for (auto it = values.constBegin(); it != end; ++it) { - if (it.key() == "valueKeys" || it.key().startsWith("value-")) + if (it.key() == "valueKeys" || it.key().view().startsWith("value-")) continue; m_sessionValues.insert(it.key(), it.value()); } diff --git a/src/plugins/cppeditor/cppcodemodelsettings.cpp b/src/plugins/cppeditor/cppcodemodelsettings.cpp index 02b22e3a54..02ec37a820 100644 --- a/src/plugins/cppeditor/cppcodemodelsettings.cpp +++ b/src/plugins/cppeditor/cppcodemodelsettings.cpp @@ -69,7 +69,7 @@ static FilePath fallbackClangdFilePath() void CppCodeModelSettings::fromSettings(QtcSettings *s) { - s->beginGroup(QLatin1String(Constants::CPPEDITOR_SETTINGSGROUP)); + s->beginGroup(Constants::CPPEDITOR_SETTINGSGROUP); setEnableLowerClazyLevels(s->value(enableLowerClazyLevelsKey(), true).toBool()); @@ -101,7 +101,7 @@ void CppCodeModelSettings::fromSettings(QtcSettings *s) void CppCodeModelSettings::toSettings(QtcSettings *s) { - s->beginGroup(QLatin1String(Constants::CPPEDITOR_SETTINGSGROUP)); + s->beginGroup(Constants::CPPEDITOR_SETTINGSGROUP); s->setValue(enableLowerClazyLevelsKey(), enableLowerClazyLevels()); s->setValue(pchUsageKey(), pchUsage()); @@ -402,7 +402,7 @@ void ClangdSettings::loadSettings() m_data.fromMap(Utils::storeFromSettings(clangdSettingsKey(), settings)); - settings->beginGroup(QLatin1String(Constants::CPPEDITOR_SETTINGSGROUP)); + settings->beginGroup(Constants::CPPEDITOR_SETTINGSGROUP); m_data.customDiagnosticConfigs = diagnosticConfigsFromSettings(settings); // Pre-8.0 compat @@ -420,7 +420,7 @@ void ClangdSettings::saveSettings() { const auto settings = Core::ICore::settings(); Utils::storeToSettings(clangdSettingsKey(), settings, m_data.toMap()); - settings->beginGroup(QLatin1String(Constants::CPPEDITOR_SETTINGSGROUP)); + settings->beginGroup(Constants::CPPEDITOR_SETTINGSGROUP); diagnosticConfigsToSettings(settings, m_data.customDiagnosticConfigs); settings->endGroup(); } diff --git a/src/plugins/debugger/debuggeractions.cpp b/src/plugins/debugger/debuggeractions.cpp index ab9d29eabf..36c2563100 100644 --- a/src/plugins/debugger/debuggeractions.cpp +++ b/src/plugins/debugger/debuggeractions.cpp @@ -290,12 +290,12 @@ QString DebuggerSettings::dump() settings().all.forEachAspect([&msg](BaseAspect *aspect) { Key key = aspect->settingsKey(); if (!key.isEmpty()) { - const int pos = key.indexOf('/'); + const int pos = key.view().indexOf('/'); if (pos >= 0) - key = key.mid(pos); + key = key.view().mid(pos).toByteArray(); const QString current = aspect->variantValue().toString(); const QString default_ = aspect->defaultVariantValue().toString(); - QString setting = key + ": " + current + " (default: " + default_ + ')'; + QString setting = stringFromKey(key) + ": " + current + " (default: " + default_ + ')'; if (current != default_) setting += " ***"; msg << setting; diff --git a/src/plugins/designer/settingsmanager.cpp b/src/plugins/designer/settingsmanager.cpp index 1cef5f4b07..59a032595d 100644 --- a/src/plugins/designer/settingsmanager.cpp +++ b/src/plugins/designer/settingsmanager.cpp @@ -13,10 +13,10 @@ namespace Designer::Internal { static Key addPrefix(const QString &name) { - Key result = keyFromString(name); + Key result; if (Core::ICore::settings()->group().isEmpty()) - result.prepend("Designer"); - return result; + result = "Designer"; + return Key(result + name.toUtf8()); } void SettingsManager::beginGroup(const QString &prefix) diff --git a/src/plugins/fakevim/fakevimactions.cpp b/src/plugins/fakevim/fakevimactions.cpp index 7440257eea..b4d568c7f0 100644 --- a/src/plugins/fakevim/fakevimactions.cpp +++ b/src/plugins/fakevim/fakevimactions.cpp @@ -244,7 +244,7 @@ FakeVimSettings::FakeVimSettings() FakeVimSettings::~FakeVimSettings() = default; -FvBaseAspect *FakeVimSettings::item(const Key &name) +FvBaseAspect *FakeVimSettings::item(const Utils::Key &name) { return m_nameToAspect.value(name, nullptr); } @@ -265,8 +265,8 @@ QString FakeVimSettings::trySetValue(const QString &name, const QString &value) void FakeVimSettings::setup(FvBaseAspect *aspect, const QVariant &value, - const Key &settingsKey, - const Key &shortName, + const Utils::Key &settingsKey, + const Utils::Key &shortName, const QString &labelText) { aspect->setSettingsKey("FakeVim", settingsKey); @@ -282,7 +282,7 @@ void FakeVimSettings::setup(FvBaseAspect *aspect, Q_UNUSED(labelText) #endif - const Key longName = settingsKey.toLower(); + const Key longName = settingsKey.toByteArray().toLower(); if (!longName.isEmpty()) { m_nameToAspect[longName] = aspect; m_aspectToName[aspect] = longName; diff --git a/src/plugins/fakevim/fakevimactions.h b/src/plugins/fakevim/fakevimactions.h index ac4256eca0..1ad91bb968 100644 --- a/src/plugins/fakevim/fakevimactions.h +++ b/src/plugins/fakevim/fakevimactions.h @@ -25,8 +25,6 @@ namespace FakeVim::Internal { #ifdef FAKEVIM_STANDALONE -using Key = QByteArray; - class FvBaseAspect { public: @@ -37,15 +35,15 @@ public: virtual void setDefaultVariantValue(const QVariant &) {} virtual QVariant variantValue() const { return {}; } virtual QVariant defaultVariantValue() const { return {}; } - void setSettingsKey(const Key &group, const Key &key); - Key settingsKey() const; + void setSettingsKey(const Utils::Key &group, const Utils::Key &key); + Utils::Key settingsKey() const; void setCheckable(bool) {} void setDisplayName(const QString &) {} void setToolTip(const QString &) {} private: - Key m_settingsGroup; - Key m_settingsKey; + Utils::Key m_settingsGroup; + Utils::Key m_settingsKey; }; template diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 4a5d8e0415..a1bee53b6a 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -6125,7 +6125,7 @@ bool FakeVimHandler::Private::handleExSetCommand(const ExCommand &cmd) if (!error.isEmpty()) showMessage(MessageError, error); } else { - Utils::Key optionName = Utils::keyFromString(cmd.args); + QString optionName = cmd.args; bool toggleOption = optionName.endsWith('!'); bool printOption = !toggleOption && optionName.endsWith('?'); @@ -6136,14 +6136,14 @@ bool FakeVimHandler::Private::handleExSetCommand(const ExCommand &cmd) if (negateOption) optionName.remove(0, 2); - FvBaseAspect *act = s.item(optionName); + FvBaseAspect *act = s.item(Utils::keyFromString(optionName)); if (!act) { showMessage(MessageError, Tr::tr("Unknown option:") + ' ' + cmd.args); } else if (act->defaultVariantValue().type() == QVariant::Bool) { bool oldValue = act->variantValue().toBool(); if (printOption) { showMessage(MessageInfo, QLatin1String(oldValue ? "" : "no") - + act->settingsKey().toLower()); + + act->settingsKey().toByteArray().toLower()); } else if (toggleOption || negateOption == oldValue) { act->setVariantValue(!oldValue); } @@ -6152,7 +6152,7 @@ bool FakeVimHandler::Private::handleExSetCommand(const ExCommand &cmd) } else if (toggleOption) { showMessage(MessageError, Tr::tr("Trailing characters:") + ' ' + cmd.args); } else { - showMessage(MessageInfo, act->settingsKey().toLower() + "=" + showMessage(MessageInfo, act->settingsKey().toByteArray().toLower() + "=" + act->variantValue().toString()); } } diff --git a/src/plugins/languageclient/languageclientsettings.cpp b/src/plugins/languageclient/languageclientsettings.cpp index d14ca1d816..8b406c2d1c 100644 --- a/src/plugins/languageclient/languageclientsettings.cpp +++ b/src/plugins/languageclient/languageclientsettings.cpp @@ -605,7 +605,7 @@ void LanguageClientSettings::init() LanguageClientManager::applySettings(); } -QList LanguageClientSettings::fromSettings(QSettings *settingsIn) +QList LanguageClientSettings::fromSettings(QtcSettings *settingsIn) { settingsIn->beginGroup(settingsGroupKey); QList result; @@ -654,7 +654,7 @@ void LanguageClientSettings::enableSettings(const QString &id, bool enable) settingsPage().enableSettings(id, enable); } -void LanguageClientSettings::toSettings(QSettings *settings, +void LanguageClientSettings::toSettings(QtcSettings *settings, const QList &languageClientSettings) { settings->beginGroup(settingsGroupKey); diff --git a/src/plugins/languageclient/languageclientsettings.h b/src/plugins/languageclient/languageclientsettings.h index 903edcba80..7c33fedad1 100644 --- a/src/plugins/languageclient/languageclientsettings.h +++ b/src/plugins/languageclient/languageclientsettings.h @@ -135,7 +135,7 @@ class LANGUAGECLIENT_EXPORT LanguageClientSettings { public: static void init(); - static QList fromSettings(QSettings *settings); + static QList fromSettings(Utils::QtcSettings *settings); static QList pageSettings(); static QList changedSettings(); @@ -146,7 +146,7 @@ public: static void registerClientType(const ClientType &type); static void addSettings(BaseSettings *settings); static void enableSettings(const QString &id, bool enable = true); - static void toSettings(QSettings *settings, const QList &languageClientSettings); + static void toSettings(Utils::QtcSettings *settings, const QList &languageClientSettings); static bool outlineComboBoxIsSorted(); static void setOutlineComboBoxSorted(bool sorted); diff --git a/src/plugins/mcusupport/test/unittest.cpp b/src/plugins/mcusupport/test/unittest.cpp index 136a083288..5692ceee75 100644 --- a/src/plugins/mcusupport/test/unittest.cpp +++ b/src/plugins/mcusupport/test/unittest.cpp @@ -694,20 +694,19 @@ void McuSupportTest::test_legacy_createPackagesWithCorrespondingSettings_data() QTest::newRow("iar_mimxrt1064_evk_freertos_json") << iar_mimxrt1064_evk_freertos_json - << QSet{{"EVK_MIMXRT1064_SDK_PATH"}, - {Key{Legacy::Constants::SETTINGS_KEY_FREERTOS_PREFIX}.append( - "IMXRT1064")}, - "IARToolchain"} + << QSet{"EVK_MIMXRT1064_SDK_PATH", + Key{QByteArray(Legacy::Constants::SETTINGS_KEY_FREERTOS_PREFIX).append("IMXRT1064")}, + "IARToolchain"} .unite(commonSettings); QTest::newRow("stm32f469i") << iar_stm32f469i_discovery_baremetal_json << QSet{{"STM32Cube_FW_F4_SDK_PATH"}, "IARToolchain"}.unite( commonSettings); - QTest::newRow("nxp1050") << armgcc_mimxrt1050_evk_freertos_json - << QSet{{"EVKB_IMXRT1050_SDK_PATH"}, - {Key{Legacy::Constants::SETTINGS_KEY_FREERTOS_PREFIX} - .append("IMXRT1050")}, - "GNUArmEmbeddedToolchain"} - .unite(commonSettings); + QTest::newRow("nxp1050") + << armgcc_mimxrt1050_evk_freertos_json + << QSet{"EVKB_IMXRT1050_SDK_PATH", + Key{QByteArray(Legacy::Constants::SETTINGS_KEY_FREERTOS_PREFIX).append("IMXRT1050")}, + "GNUArmEmbeddedToolchain"} + .unite(commonSettings); QTest::newRow("armgcc_stm32h750b_discovery_baremetal_json") << armgcc_stm32h750b_discovery_baremetal_json << QSet{{"STM32Cube_FW_H7_SDK_PATH"}, "GNUArmEmbeddedToolchain"}.unite( diff --git a/src/plugins/perfprofiler/perfsettings.cpp b/src/plugins/perfprofiler/perfsettings.cpp index e8524e6395..456f8909a9 100644 --- a/src/plugins/perfprofiler/perfsettings.cpp +++ b/src/plugins/perfprofiler/perfsettings.cpp @@ -428,11 +428,11 @@ void PerfSettings::readGlobalSettings() Store defaults; // Read stored values - QSettings *settings = Core::ICore::settings(); - settings->beginGroup(QLatin1String(Constants::AnalyzerSettingsGroupId)); + QtcSettings *settings = Core::ICore::settings(); + settings->beginGroup(Constants::AnalyzerSettingsGroupId); Store map = defaults; for (Store::ConstIterator it = defaults.constBegin(); it != defaults.constEnd(); ++it) - map.insert(it.key(), settings->value(stringFromKey(it.key()), it.value())); + map.insert(it.key(), settings->value(it.key(), it.value())); settings->endGroup(); fromMap(map); @@ -440,12 +440,12 @@ void PerfSettings::readGlobalSettings() void PerfSettings::writeGlobalSettings() const { - QSettings *settings = Core::ICore::settings(); - settings->beginGroup(QLatin1String(Constants::AnalyzerSettingsGroupId)); + QtcSettings *settings = Core::ICore::settings(); + settings->beginGroup(Constants::AnalyzerSettingsGroupId); Store map; toMap(map); for (Store::ConstIterator it = map.constBegin(); it != map.constEnd(); ++it) - settings->setValue(stringFromKey(it.key()), it.value()); + settings->setValue(it.key(), it.value()); settings->endGroup(); } diff --git a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp index 7cfe6faba4..1337e2183f 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp @@ -225,8 +225,8 @@ QWidget *CustomWizardFieldPage::registerPathChooser(const QString &fieldName, pathChooser->setExpectedKind(PathChooser::Command); else if (expectedKind == QLatin1String("any")) pathChooser->setExpectedKind(PathChooser::Any); - pathChooser->setHistoryCompleter("PE.Custom." + m_parameters->id.name() - + '.' + keyFromString(field.name)); + pathChooser->setHistoryCompleter(keyFromString("PE.Custom." + m_parameters->id.name() + + '.' + field.name)); registerField(fieldName, pathChooser, "path", SIGNAL(rawPathChanged(QString))); // Connect to completeChanged() for derived classes that reimplement isComplete() diff --git a/src/plugins/projectexplorer/editorconfiguration.cpp b/src/plugins/projectexplorer/editorconfiguration.cpp index 33e2b4d9c8..5230caeba7 100644 --- a/src/plugins/projectexplorer/editorconfiguration.cpp +++ b/src/plugins/projectexplorer/editorconfiguration.cpp @@ -218,8 +218,8 @@ void EditorConfiguration::fromMap(const Store &map) Store submap; for (auto it = map.constBegin(), end = map.constEnd(); it != end; ++it) { - if (it.key().startsWith(kPrefix)) - submap.insert(it.key().mid(kPrefix.size()), it.value()); + if (it.key().view().startsWith(kPrefix.view())) + submap.insert(it.key().view().mid(kPrefix.view().size()).toByteArray(), it.value()); } d->m_defaultCodeStyle->fromMap(submap); d->m_typingSettings.fromMap(submap); diff --git a/src/plugins/projectexplorer/extraabi.cpp b/src/plugins/projectexplorer/extraabi.cpp index 8099238156..619d66733f 100644 --- a/src/plugins/projectexplorer/extraabi.cpp +++ b/src/plugins/projectexplorer/extraabi.cpp @@ -62,10 +62,12 @@ void ExtraAbi::load() std::vector oses; for (const QString &osName : osNames) { Abi::OS os = Abi::osFromString(osName); - if (Abi::toString(os) != osName) - qWarning() << "Invalid OS found when registering extra abi flavor" << it.key(); - else + if (Abi::toString(os) != osName) { + qWarning() << "Invalid OS found when registering extra abi flavor" + << it.key().toByteArray(); + } else { oses.push_back(os); + } } Abi::registerOsFlavor(oses, stringFromKey(flavor)); diff --git a/src/plugins/projectexplorer/userfileaccessor.cpp b/src/plugins/projectexplorer/userfileaccessor.cpp index d4b413ae12..467fe0c0a8 100644 --- a/src/plugins/projectexplorer/userfileaccessor.cpp +++ b/src/plugins/projectexplorer/userfileaccessor.cpp @@ -802,7 +802,8 @@ QVariant UserFileVersion19Upgrader::process(const QVariant &entry, const KeyList for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) { Key key = it.key(); QVariant value = it.value(); - if (path.size() == 2 && path.at(1).startsWith("ProjectExplorer.Target.RunConfiguration.")) { + if (path.size() == 2 + && path.at(1).view().startsWith("ProjectExplorer.Target.RunConfiguration.")) { if (argsKeys.contains(key)) key = "RunConfiguration.Arguments"; else if (wdKeys.contains(key)) diff --git a/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp index fbfa7cee52..f7735415c4 100644 --- a/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/qtwizard.cpp @@ -89,7 +89,7 @@ QString QtWizard::templateDir() bool QtWizard::lowerCaseFiles() { - Key lowerCaseSettingsKey = CppEditor::Constants::CPPEDITOR_SETTINGSGROUP; + QByteArray lowerCaseSettingsKey = CppEditor::Constants::CPPEDITOR_SETTINGSGROUP; lowerCaseSettingsKey += '/'; lowerCaseSettingsKey += CppEditor::Constants::LOWERCASE_CPPFILES_KEY; const bool lowerCaseDefault = CppEditor::Constants::LOWERCASE_CPPFILES_DEFAULT; diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp index 4cfe178e6d..8cc5685723 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -765,7 +765,7 @@ void QtVersion::fromMap(const Store &map, const FilePath &filePath, bool forceRe d->m_qmakeCommand = filePath.resolvePath(d->m_qmakeCommand); const expected_str persistentStore = PersistentCacheStore::byKey( - "QtVersionData" + d->m_qmakeCommand.toString().toUtf8()); + Key("QtVersionData" + d->m_qmakeCommand.toString().toUtf8())); if (persistentStore && !forceRefreshCache) { d->m_data.fromMap(*persistentStore); @@ -799,7 +799,7 @@ Store QtVersion::toMap() const result.insert(QTVERSIONQMAKEPATH, qmakeFilePath().toSettings()); if (d->m_data.versionInfoUpToDate) - PersistentCacheStore::write("QtVersionData" + d->m_qmakeCommand.toString().toUtf8(), + PersistentCacheStore::write(Key("QtVersionData" + d->m_qmakeCommand.toString().toUtf8()), d->m_data.toMap()); return result; @@ -1407,7 +1407,7 @@ void QtVersionPrivate::updateVersionInfo() m_isUpdating = false; m_data.versionInfoUpToDate = true; - PersistentCacheStore::write("QtVersionData" + m_qmakeCommand.toString().toUtf8(), + PersistentCacheStore::write(Key("QtVersionData" + m_qmakeCommand.toString().toUtf8()), m_data.toMap()); } diff --git a/src/plugins/qtsupport/qtversionmanager.cpp b/src/plugins/qtsupport/qtversionmanager.cpp index c329d24db0..4674bb0707 100644 --- a/src/plugins/qtsupport/qtversionmanager.cpp +++ b/src/plugins/qtsupport/qtversionmanager.cpp @@ -213,14 +213,14 @@ bool QtVersionManagerImpl::restoreQtVersions() if (version < 1) return false; - const Key keyPrefix(QTVERSION_DATA_KEY); + const QByteArray keyPrefix(QTVERSION_DATA_KEY); const Store::ConstIterator dcend = data.constEnd(); for (Store::ConstIterator it = data.constBegin(); it != dcend; ++it) { const Key &key = it.key(); - if (!key.startsWith(keyPrefix)) + if (!key.view().startsWith(keyPrefix)) continue; bool ok; - int count = key.mid(keyPrefix.count()).toInt(&ok); + int count = key.view().mid(keyPrefix.count()).toInt(&ok); if (!ok || count < 0) continue; @@ -287,14 +287,14 @@ void QtVersionManagerImpl::updateFromInstaller(bool emitSignal) QStringList sdkVersions; - const Key keyPrefix(QTVERSION_DATA_KEY); + const QByteArray keyPrefix(QTVERSION_DATA_KEY); const Store::ConstIterator dcend = data.constEnd(); for (Store::ConstIterator it = data.constBegin(); it != dcend; ++it) { const Key &key = it.key(); - if (!key.startsWith(keyPrefix)) + if (!key.view().startsWith(keyPrefix)) continue; bool ok; - int count = key.mid(keyPrefix.count()).toInt(&ok); + int count = key.view().mid(keyPrefix.count()).toInt(&ok); if (!ok || count < 0) continue; -- cgit v1.2.3