diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-05-18 14:26:39 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-05-19 10:16:23 +0200 |
commit | 19b6ae6637bde73ec508b6d1d29f3233e2c4e2d4 (patch) | |
tree | 1136013f9c4e7ca7083de83e2b9164f351bdfb14 /src/corelib/global/qlibraryinfo.cpp | |
parent | 941039356df56dfbf5a4b4f828a577ca8b8fb025 (diff) |
Fix relocated Qt to be found when its path has non-ASCII characters
The path returned by dladdr seems to be encoded with the current
locale encoding which means that if it contains unicode characters, the
fromLatin1() call mangles the path, and QFile::exists reports that
the path does not exist.
To preserve non-ASCII characters use fromLocal8Bit() instead.
This should fix the runtime issue of finding the Qt prefix when the
Qt library path has non-ASCII characters.
Amends 2f52afda8e77429c00029f94e887ed37dfb4e584.
Amends 4ac872639ed0dd3ae6627e05bdda821f7d128500.
Fixes: QTBUG-84272
Task-number: QTBUG-15234
Pick-to: 5.14 5.15
Change-Id: I37019ed219cf2cf7d9663cb1e16acdb97b3bdf09
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qlibraryinfo.cpp')
-rw-r--r-- | src/corelib/global/qlibraryinfo.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 871b2071fd..bfbc4ce1e5 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -576,7 +576,7 @@ static QString getRelocatablePrefix() Dl_info info; int result = dladdr(reinterpret_cast<void *>(&QLibraryInfo::isDebugBuild), &info); if (result > 0 && info.dli_fname) - prefixPath = prefixFromQtCoreLibraryHelper(QString::fromLatin1(info.dli_fname)); + prefixPath = prefixFromQtCoreLibraryHelper(QString::fromLocal8Bit(info.dli_fname)); #elif defined(Q_OS_WIN) HMODULE hModule = getWindowsModuleHandle(); const int kBufferSize = 4096; @@ -590,7 +590,7 @@ static QString getRelocatablePrefix() // QtCore DLL is next to the executable. This is either a windeployqt'ed executable or an // executable within the QT_HOST_BIN directory. We're detecting the latter case by checking // whether there's an import library corresponding to our QtCore DLL in PREFIX/lib. - const QString libdir = QString::fromLatin1( + const QString libdir = QString::fromLocal8Bit( qt_configure_strs + qt_configure_str_offsets[QLibraryInfo::LibrariesPath - 1]); const QLatin1Char slash('/'); #if defined(Q_CC_MINGW) @@ -622,7 +622,7 @@ static QString getRelocatablePrefix() // QTBUG-78948: libQt5Core.so may be located in subdirectories below libdir. // See "Hardware capabilities" in the ld.so documentation and the Qt 5.3.0 // changelog regarding SSE2 support. - const QString libdir = QString::fromLatin1( + const QString libdir = QString::fromLocal8Bit( qt_configure_strs + qt_configure_str_offsets[QLibraryInfo::LibrariesPath - 1]); QDir prefixDir(prefixPath); while (!prefixDir.exists(libdir)) { |