CoreText: Handle failure to find matching theme font descriptors

CTFontDescriptorCreateMatchingFontDescriptors has been observed to
return nullptr, so we need to handle that explicitly.

Fixes: QTBUG-113698
Change-Id: Ic9fa574c14068fcae98fe8e6ceddd8a4f7008210
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 9526a7693604c5513a08a4ab08c0c691c3003f39)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2023-06-27 18:22:16 +02:00 committed by Qt Cherry-pick Bot
parent 77573a04aa
commit 7eb7da8e52

View File

@ -905,7 +905,7 @@ void QCoreTextFontDatabase::populateThemeFonts()
auto addFontVariants = [&](CTFontDescriptorRef descriptor) { auto addFontVariants = [&](CTFontDescriptorRef descriptor) {
QCFType<CFArrayRef> matchingDescriptors = CTFontDescriptorCreateMatchingFontDescriptors(descriptor, nullptr); QCFType<CFArrayRef> matchingDescriptors = CTFontDescriptorCreateMatchingFontDescriptors(descriptor, nullptr);
const int matchingDescriptorsCount = CFArrayGetCount(matchingDescriptors); const int matchingDescriptorsCount = matchingDescriptors ? CFArrayGetCount(matchingDescriptors) : 0;
qCDebug(lcQpaFonts) << "Enumerating font variants based on" << id(descriptor) qCDebug(lcQpaFonts) << "Enumerating font variants based on" << id(descriptor)
<< "resulted in" << matchingDescriptorsCount << "matching descriptors" << "resulted in" << matchingDescriptorsCount << "matching descriptors"
<< matchingDescriptors.as<NSArray*>(); << matchingDescriptors.as<NSArray*>();