From 2ea099b67943634a06bce642e13062f84de7e3be Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 10 Oct 2024 13:03:22 +0200 Subject: [PATCH] Windows: Release old references when invalidating DirectWrite db MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the font database is invalidated, we need to release all references to populated fonts and clear the lists, so that they can be repopulated from scratch. This was not really measurable as long as the contents of the database did not change, but it was a possible source of errors. Pick-to: 6.8 Task-number: QTBUG-129849 Change-Id: Ic7ed4abcb13f13332e8edb77e2039f08da9660fd Reviewed-by: Tor Arne Vestbø --- .../windows/qwindowsdirectwritefontdatabase.cpp | 13 +++++++++++++ .../windows/qwindowsdirectwritefontdatabase_p.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp b/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp index e5e71cdaaef..610cd1d64b0 100644 --- a/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp +++ b/src/gui/text/windows/qwindowsdirectwritefontdatabase.cpp @@ -801,4 +801,17 @@ bool QWindowsDirectWriteFontDatabase::supportsVariableApplicationFonts() const return false; } +void QWindowsDirectWriteFontDatabase::invalidate() +{ + QWindowsFontDatabase::invalidate(); + + for (IDWriteFontFamily *value : m_populatedFonts) + value->Release(); + m_populatedFonts.clear(); + m_populatedFonts.squeeze(); + + m_populatedBitmapFonts.clear(); + m_populatedBitmapFonts.squeeze(); +} + QT_END_NAMESPACE diff --git a/src/gui/text/windows/qwindowsdirectwritefontdatabase_p.h b/src/gui/text/windows/qwindowsdirectwritefontdatabase_p.h index 3b2bba4d7b6..3e5e9663a96 100644 --- a/src/gui/text/windows/qwindowsdirectwritefontdatabase_p.h +++ b/src/gui/text/windows/qwindowsdirectwritefontdatabase_p.h @@ -59,6 +59,9 @@ public: return m_populatedFonts.contains(fontFamily); } +protected: + void invalidate() override; + private: friend class QWindowsFontEngineDirectWrite; static QString localeString(IDWriteLocalizedStrings *names, wchar_t localeName[]);