Windows: Release old references when invalidating DirectWrite db

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.

Task-number: QTBUG-129849
Change-Id: Ic7ed4abcb13f13332e8edb77e2039f08da9660fd
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 2ea099b67943634a06bce642e13062f84de7e3be)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2024-10-10 13:03:22 +02:00 committed by Qt Cherry-pick Bot
parent 6dfe5c847e
commit 7bf79ee390
2 changed files with 16 additions and 0 deletions

View File

@ -801,4 +801,17 @@ bool QWindowsDirectWriteFontDatabase::supportsVariableApplicationFonts() const
return false; 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 QT_END_NAMESPACE

View File

@ -59,6 +59,9 @@ public:
return m_populatedFonts.contains(fontFamily); return m_populatedFonts.contains(fontFamily);
} }
protected:
void invalidate() override;
private: private:
friend class QWindowsFontEngineDirectWrite; friend class QWindowsFontEngineDirectWrite;
static QString localeString(IDWriteLocalizedStrings *names, wchar_t localeName[]); static QString localeString(IDWriteLocalizedStrings *names, wchar_t localeName[]);