Direct Write Font Engine: Fix leaking IDWriteFontFace instances

Patch as contributed on bug report.

Pick-to: 5.15
Pick-to: 5.12
Fixes: QTBUG-84265
Change-Id: I73d73cf7d1b46944767750bf0f0c727c7b00b1d7
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Friedemann Kleint 2020-05-18 09:30:10 +02:00
parent 1b7589a25c
commit 26100ccb83

View File

@ -1175,6 +1175,8 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, const Q
reinterpret_cast<void **>(&directWriteFontFace2)))) {
if (directWriteFontFace2->IsColorFont())
isColorFont = directWriteFontFace2->GetPaletteEntryCount() > 0;
directWriteFontFace2->Release();
}
#endif
useDw = useDw || useDirectWrite(hintingPreference, fam, isColorFont);
@ -1196,9 +1198,8 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, const Q
fedw->glyphFormat = QFontEngine::Format_ARGB;
fedw->initFontInfo(fontDef, dpi);
fe = fedw;
} else {
directWriteFontFace->Release();
}
directWriteFontFace->Release();
} else if (useDw) {
const QString errorString = qt_error_string(int(hr));
qWarning().noquote().nospace() << "DirectWrite: CreateFontFaceFromHDC() failed ("