Fix crash on macOS with -qtlibinfix'ed Qt

When Qt is configured with -qtlibinfix Foo then the prefix determination code
in QLibraryInfo crashed, because it still assumed the library name to be
"QtCore".

Fixes: QTBUG-83912
Pick-to: 5.15
Change-Id: I104e115ac6904fc0a04ac45d68d26d4e02aba721
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
bb10
Joerg Bornemann 2020-05-13 14:32:08 +02:00
parent 92df790f46
commit 46fb39ef5a
1 changed files with 5 additions and 2 deletions

View File

@ -534,7 +534,10 @@ static QString getRelocatablePrefix()
#if defined(QT_STATIC)
prefixPath = prefixFromAppDirHelper();
#elif defined(Q_OS_DARWIN) && QT_CONFIG(framework)
auto qtCoreBundle = CFBundleGetBundleWithIdentifier(CFSTR("org.qt-project.QtCore"));
#ifndef QT_LIBINFIX
#define QT_LIBINFIX ""
#endif
auto qtCoreBundle = CFBundleGetBundleWithIdentifier(CFSTR("org.qt-project.QtCore" QT_LIBINFIX));
if (!qtCoreBundle) {
// When running Qt apps over Samba shares, CoreFoundation will fail to find
// the Resources directory inside the bundle, This directory is a symlink,
@ -547,7 +550,7 @@ static QString getRelocatablePrefix()
auto bundle = CFBundleRef(CFArrayGetValueAtIndex(allBundles, i));
auto url = QCFType<CFURLRef>(CFBundleCopyBundleURL(bundle));
auto path = QCFType<CFStringRef>(CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle));
if (CFStringHasSuffix(path, CFSTR("/QtCore.framework"))) {
if (CFStringHasSuffix(path, CFSTR("/QtCore" QT_LIBINFIX ".framework"))) {
qtCoreBundle = bundle;
break;
}