re-arrange QLibraryInfo::rawLocation() for comprehensibility

swap the branches for (not) reading from qt.conf, and use a state
variable instead of an 'else' for mutual exclusion. this is somewhat
more self-documenting, and allows for a saner handling of the mkspec
fallbacks (which really should have been in a separate [QMake] section
along with Host* and Sysroot, but changing that now is way too much
hassle downstream).

Change-Id: I80a73294022fd1e8d84fe501b737c4fc7758662f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Oswald Buddenhagen 2016-11-07 19:02:43 +01:00
parent c16593fd0b
commit 4d90bd55a5

View File

@ -449,6 +449,8 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
{
#endif // QT_BUILD_QMAKE, started inside location !
QString ret;
bool fromConf = false;
#ifndef QT_NO_SETTINGS
#ifdef QT_BUILD_QMAKE
// Logic for choosing the right data source: if EffectivePaths are requested
// and qt.conf with that section is present, use it, otherwise fall back to
@ -457,40 +459,18 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
// EffectiveSourcePaths falls back to EffectivePaths.
// DevicePaths falls back to FinalPaths.
PathGroup orig_group = group;
if (!QLibraryInfoPrivate::haveGroup(group)
&& !(group == EffectiveSourcePaths
&& (group = EffectivePaths, QLibraryInfoPrivate::haveGroup(group)))
&& !((group == EffectivePaths || group == DevicePaths)
&& (group = FinalPaths, QLibraryInfoPrivate::haveGroup(group)))
&& (group = orig_group, true))
#elif !defined(QT_NO_SETTINGS)
if (!QLibraryInfoPrivate::configuration())
if (QLibraryInfoPrivate::haveGroup(group)
|| (group == EffectiveSourcePaths
&& (group = EffectivePaths, QLibraryInfoPrivate::haveGroup(group)))
|| ((group == EffectivePaths || group == DevicePaths)
&& (group = FinalPaths, QLibraryInfoPrivate::haveGroup(group)))
|| (group = orig_group, false))
#else
if (QLibraryInfoPrivate::configuration())
#endif
{
const char * volatile path = 0;
if (loc == PrefixPath) {
path =
#ifdef QT_BUILD_QMAKE
(group != DevicePaths) ?
QT_CONFIGURE_EXT_PREFIX_PATH :
#endif
QT_CONFIGURE_PREFIX_PATH;
} else if (unsigned(loc) <= sizeof(qt_configure_str_offsets)/sizeof(qt_configure_str_offsets[0])) {
path = qt_configure_strs + qt_configure_str_offsets[loc - 1];
#ifndef Q_OS_WIN // On Windows we use the registry
} else if (loc == SettingsPath) {
path = QT_CONFIGURE_SETTINGS_PATH;
#endif
#ifdef QT_BUILD_QMAKE
} else if (loc == HostPrefixPath) {
path = QT_CONFIGURE_HOST_PREFIX_PATH;
#endif
}
fromConf = true;
if (path)
ret = QString::fromLocal8Bit(path);
#ifndef QT_NO_SETTINGS
} else {
QString key;
QString defaultValue;
if (unsigned(loc) < sizeof(qtConfEntries)/sizeof(qtConfEntries[0])) {
@ -522,7 +502,9 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
ret = config->value(QLatin1String(qtConfEntries[PrefixPath].key),
QLatin1String(qtConfEntries[PrefixPath].value)).toString();
else if (loc == TargetSpecPath || loc == HostSpecPath)
ret = QString::fromLocal8Bit(qt_configure_strs + qt_configure_str_offsets[loc - 1]);
fromConf = false;
// The last case here is SysrootPath, which can be legitimately empty.
// All other keys have non-empty fallbacks to start with.
}
#endif
@ -540,7 +522,32 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
ret = QDir::fromNativeSeparators(ret);
}
}
#endif // QT_NO_SETTINGS
if (!fromConf) {
const char * volatile path = 0;
if (loc == PrefixPath) {
path =
#ifdef QT_BUILD_QMAKE
(group != DevicePaths) ?
QT_CONFIGURE_EXT_PREFIX_PATH :
#endif
QT_CONFIGURE_PREFIX_PATH;
} else if (unsigned(loc) <= sizeof(qt_configure_str_offsets)/sizeof(qt_configure_str_offsets[0])) {
path = qt_configure_strs + qt_configure_str_offsets[loc - 1];
#ifndef Q_OS_WIN // On Windows we use the registry
} else if (loc == SettingsPath) {
path = QT_CONFIGURE_SETTINGS_PATH;
#endif
#ifdef QT_BUILD_QMAKE
} else if (loc == HostPrefixPath) {
path = QT_CONFIGURE_HOST_PREFIX_PATH;
#endif
}
if (path)
ret = QString::fromLocal8Bit(path);
}
#ifdef QT_BUILD_QMAKE