Reduce scope of a hack using volatile in favor of viewAt()
We can now get qt_configure_strs to tell us the size of the string, as well as its start, bypassing the strlen()-calling branch of fromLocal8Bit() that caused the need for a hack using a volatile variable. However, QT_CONFIGURE_SETTINGS_PATH still needs the volatile hack. Change-Id: I0181abf512123e6355acdd506d6845c3fb75c0e3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
4d4aa6e21c
commit
4ef8e9427c
@ -602,24 +602,20 @@ QString QLibraryInfo::path(LibraryPath p)
|
|||||||
#endif // settings
|
#endif // settings
|
||||||
|
|
||||||
if (!fromConf) {
|
if (!fromConf) {
|
||||||
// "volatile" here is a hack to prevent compilers from doing a
|
|
||||||
// compile-time strlen() on "path". The issue is that Qt installers
|
|
||||||
// will binary-patch the Qt installation paths -- in such scenarios, Qt
|
|
||||||
// will be built with a dummy path, thus the compile-time result of
|
|
||||||
// strlen is meaningless.
|
|
||||||
const char * volatile path = nullptr;
|
|
||||||
if (loc == PrefixPath) {
|
if (loc == PrefixPath) {
|
||||||
ret = getPrefix();
|
ret = getPrefix();
|
||||||
} else if (int(loc) <= qt_configure_strs.count()) {
|
} else if (int(loc) <= qt_configure_strs.count()) {
|
||||||
path = qt_configure_strs[loc - 1];
|
ret = QString::fromLocal8Bit(qt_configure_strs.viewAt(loc - 1));
|
||||||
#ifndef Q_OS_WIN // On Windows we use the registry
|
#ifndef Q_OS_WIN // On Windows we use the registry
|
||||||
} else if (loc == SettingsPath) {
|
} else if (loc == SettingsPath) {
|
||||||
path = QT_CONFIGURE_SETTINGS_PATH;
|
// Use of volatile is a hack to discourage compilers from calling
|
||||||
|
// strlen(), in the inlined fromLocal8Bit(const char *)'s body, at
|
||||||
|
// compile-time, as Qt installers binary-patch the path, replacing
|
||||||
|
// the dummy path seen at compile-time, typically changing length.
|
||||||
|
const char *volatile path = QT_CONFIGURE_SETTINGS_PATH;
|
||||||
|
ret = QString::fromLocal8Bit(path);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path)
|
|
||||||
ret = QString::fromLocal8Bit(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret.isEmpty() && QDir::isRelativePath(ret)) {
|
if (!ret.isEmpty() && QDir::isRelativePath(ret)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user