From 6dfe5c847e061de7bf2971ce10dca0489a781f81 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 10 Oct 2024 12:57:03 +0200 Subject: [PATCH] Windows: Fix memory leak in DirectWrite font database MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø (cherry picked from commit 247cd80abdd5fc0bc6243581e506354a5509518e) Reviewed-by: Qt Cherry-pick Bot --- src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp b/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp index 2a6b1a53f9..e5e71cdaae 100644 --- a/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp +++ b/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp @@ -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 font; if (SUCCEEDED(matchingFonts->GetFont(j, &font))) { DirectWriteScope font1; if (!SUCCEEDED(font->QueryInterface(__uuidof(IDWriteFont1),