summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2021-03-05 12:36:10 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2021-03-11 09:59:42 +0100
commitb788c87457100dfaa92f77d24f3d7fab4798ab6b (patch)
tree787aa2d139434968d013b98f510ea5c81aa0dfc3 /qmake
parent17055f5f4833ba96f7d361c7113a88d973a0e186 (diff)
QMakeLibraryInfo: Move reading of default values into separate function
Reduce code duplication. Change-Id: Ic20c124ad664d16552e3cfea8dde465fc0b6066f Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'qmake')
-rw-r--r--qmake/qmakelibraryinfo.cpp52
1 files changed, 31 insertions, 21 deletions
diff --git a/qmake/qmakelibraryinfo.cpp b/qmake/qmakelibraryinfo.cpp
index c118725d27..4a101ebb6c 100644
--- a/qmake/qmakelibraryinfo.cpp
+++ b/qmake/qmakelibraryinfo.cpp
@@ -156,6 +156,28 @@ QString QMakeLibraryInfo::path(int loc)
return ret;
}
+struct LocationInfo
+{
+ QString key;
+ QString defaultValue;
+};
+
+static LocationInfo defaultLocationInfo(int loc)
+{
+ LocationInfo result;
+ if (unsigned(loc) < sizeof(qtConfEntries) / sizeof(qtConfEntries[0])) {
+ result.key = QLatin1String(qtConfEntries[loc].key);
+ result.defaultValue = QLatin1String(qtConfEntries[loc].value);
+ }
+#ifndef Q_OS_WIN // On Windows we use the registry
+ else if (loc == QLibraryInfo::SettingsPath) {
+ result.key = QLatin1String("Settings");
+ result.defaultValue = QLatin1String(".");
+ }
+#endif
+ return result;
+}
+
QString QMakeLibraryInfo::rawLocation(int loc, QMakeLibraryInfo::PathGroup group)
{
QString ret;
@@ -175,19 +197,8 @@ QString QMakeLibraryInfo::rawLocation(int loc, QMakeLibraryInfo::PathGroup group
|| (group = orig_group, false)) {
fromConf = true;
- QString key;
- QString defaultValue;
- if (unsigned(loc) < sizeof(qtConfEntries) / sizeof(qtConfEntries[0])) {
- key = QLatin1String(qtConfEntries[loc].key);
- defaultValue = QLatin1String(qtConfEntries[loc].value);
- }
-#ifndef Q_OS_WIN // On Windows we use the registry
- else if (loc == QLibraryInfo::SettingsPath) {
- key = QLatin1String("Settings");
- defaultValue = QLatin1String(".");
- }
-#endif
- if (!key.isNull()) {
+ LocationInfo locinfo = defaultLocationInfo(loc);
+ if (!locinfo.key.isNull()) {
QSettings *config = QMakeLibraryInfo::configuration();
config->beginGroup(QLatin1String(group == DevicePaths ? "DevicePaths"
: group == EffectiveSourcePaths
@@ -195,17 +206,16 @@ QString QMakeLibraryInfo::rawLocation(int loc, QMakeLibraryInfo::PathGroup group
: group == EffectivePaths ? "EffectivePaths"
: "Paths"));
- ret = config->value(key, defaultValue).toString();
+ ret = config->value(locinfo.key, locinfo.defaultValue).toString();
if (ret.isEmpty()) {
- if (loc == HostPrefixPath)
- ret = config->value(QLatin1String(qtConfEntries[QLibraryInfo::PrefixPath].key),
- QLatin1String(
- qtConfEntries[QLibraryInfo::PrefixPath].value))
- .toString();
- else if (loc == TargetSpecPath || loc == HostSpecPath
- || loc == SysrootifyPrefixPath)
+ if (loc == HostPrefixPath) {
+ locinfo = defaultLocationInfo(QLibraryInfo::PrefixPath);
+ ret = config->value(locinfo.key, locinfo.defaultValue).toString();
+ } else if (loc == TargetSpecPath || loc == HostSpecPath
+ || loc == SysrootifyPrefixPath) {
fromConf = false;
+ }
// The last case here is SysrootPath, which can be legitimately empty.
// All other keys have non-empty fallbacks to start with.
}