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:
parent
c16593fd0b
commit
4d90bd55a5
@ -449,6 +449,8 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
|
|||||||
{
|
{
|
||||||
#endif // QT_BUILD_QMAKE, started inside location !
|
#endif // QT_BUILD_QMAKE, started inside location !
|
||||||
QString ret;
|
QString ret;
|
||||||
|
bool fromConf = false;
|
||||||
|
#ifndef QT_NO_SETTINGS
|
||||||
#ifdef QT_BUILD_QMAKE
|
#ifdef QT_BUILD_QMAKE
|
||||||
// Logic for choosing the right data source: if EffectivePaths are requested
|
// 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
|
// 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.
|
// EffectiveSourcePaths falls back to EffectivePaths.
|
||||||
// DevicePaths falls back to FinalPaths.
|
// DevicePaths falls back to FinalPaths.
|
||||||
PathGroup orig_group = group;
|
PathGroup orig_group = group;
|
||||||
if (!QLibraryInfoPrivate::haveGroup(group)
|
if (QLibraryInfoPrivate::haveGroup(group)
|
||||||
&& !(group == EffectiveSourcePaths
|
|| (group == EffectiveSourcePaths
|
||||||
&& (group = EffectivePaths, QLibraryInfoPrivate::haveGroup(group)))
|
&& (group = EffectivePaths, QLibraryInfoPrivate::haveGroup(group)))
|
||||||
&& !((group == EffectivePaths || group == DevicePaths)
|
|| ((group == EffectivePaths || group == DevicePaths)
|
||||||
&& (group = FinalPaths, QLibraryInfoPrivate::haveGroup(group)))
|
&& (group = FinalPaths, QLibraryInfoPrivate::haveGroup(group)))
|
||||||
&& (group = orig_group, true))
|
|| (group = orig_group, false))
|
||||||
#elif !defined(QT_NO_SETTINGS)
|
#else
|
||||||
if (!QLibraryInfoPrivate::configuration())
|
if (QLibraryInfoPrivate::configuration())
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
const char * volatile path = 0;
|
fromConf = true;
|
||||||
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);
|
|
||||||
#ifndef QT_NO_SETTINGS
|
|
||||||
} else {
|
|
||||||
QString key;
|
QString key;
|
||||||
QString defaultValue;
|
QString defaultValue;
|
||||||
if (unsigned(loc) < sizeof(qtConfEntries)/sizeof(qtConfEntries[0])) {
|
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),
|
ret = config->value(QLatin1String(qtConfEntries[PrefixPath].key),
|
||||||
QLatin1String(qtConfEntries[PrefixPath].value)).toString();
|
QLatin1String(qtConfEntries[PrefixPath].value)).toString();
|
||||||
else if (loc == TargetSpecPath || loc == HostSpecPath)
|
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
|
#endif
|
||||||
|
|
||||||
@ -540,7 +522,32 @@ QLibraryInfo::rawLocation(LibraryLocation loc, PathGroup group)
|
|||||||
|
|
||||||
ret = QDir::fromNativeSeparators(ret);
|
ret = QDir::fromNativeSeparators(ret);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif // QT_NO_SETTINGS
|
#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
|
#ifdef QT_BUILD_QMAKE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user