Windows: Fix memory leak in DirectWrite font database

In ec38f0002de74f343e808c2f5d6363003f5264e8, we introduced a guard
for automatically releasing references to DirectWrite types to plug
a small leak. Unfortunately, this change removed a call to Release()
without putting the pointer inside a guard, hence it introduced
another leak. This was noticeable if the font database was invalidated
and repopulated multiple times.

[ChangeLog][Windows] Fixed a memory leak when repopulating the
DirectWrite font database.

Task-number: QTBUG-129849
Change-Id: I59e3132b6836501b7756679ffac82fb65e3027cb
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 247cd80abdd5fc0bc6243581e506354a5509518e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2024-10-10 12:57:03 +02:00 committed by Qt Cherry-pick Bot
parent 5c675fb298
commit 6dfe5c847e

View File

@ -136,7 +136,7 @@ void QWindowsDirectWriteFontDatabase::populateFamily(const QString &familyName)
DWRITE_FONT_STYLE_NORMAL,
&matchingFonts))) {
for (uint j = 0; j < matchingFonts->GetFontCount(); ++j) {
IDWriteFont *font;
DirectWriteScope<IDWriteFont> font;
if (SUCCEEDED(matchingFonts->GetFont(j, &font))) {
DirectWriteScope<IDWriteFont1> font1;
if (!SUCCEEDED(font->QueryInterface(__uuidof(IDWriteFont1),