summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-05-18 14:26:39 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-05-19 20:38:39 +0000
commit973f0cee9e8134f2a647281aa36bc28d9255a1ee (patch)
tree0183adedc54f146f796539d4546b7295ebfea3d5 /src/corelib/global
parentf7a0bbc7b3c16977fab1903ee732e03e91c96cfa (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 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> (cherry picked from commit 19b6ae6637bde73ec508b6d1d29f3233e2c4e2d4) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qlibraryinfo.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index df9ef77fb2..8ceb763491 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -577,7 +577,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;
@@ -591,7 +591,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)
@@ -623,7 +623,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)) {