diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2022-03-18 12:46:41 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2022-04-01 18:54:30 +0200 |
commit | 678548afe8b36b9c7b447443343a4ea713103363 (patch) | |
tree | 7b1f30771ab8d83b84f3cd724eefa98a86dfad21 /src/gui/text/qfontdatabase.cpp | |
parent | 919f514f29f33d653e492b0dbf9fc95d7cd93287 (diff) |
Flush font cache when we load new application fonts
If new application fonts are loaded during the lifetime of the
application, it's possible that we have already cached fallbacks
for requests for the newly loaded font families. To make sure we
redo requests for the updated database, we have to flush the cache,
just like we do when removing application fonts.
Task-number: QTBUG-100697
Task-number: QDS-1142
Change-Id: I2a6d2a7459187d69d14ef639e2b710c8d553b86e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui/text/qfontdatabase.cpp')
-rw-r--r-- | src/gui/text/qfontdatabase.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp index dc2a0ff623..020e02d520 100644 --- a/src/gui/text/qfontdatabase.cpp +++ b/src/gui/text/qfontdatabase.cpp @@ -2136,10 +2136,16 @@ int QFontDatabasePrivate::addAppFont(const QByteArray &fontData, const QString & applicationFonts[i] = font; // If the cache has not yet been populated, we need to reload the application font later - if (wasEmpty) + if (wasEmpty) { invalidate(); - else + } else { emit qApp->fontDatabaseChanged(); + + // The font cache may have cached lookups for the font that was now + // loaded, so it has to be flushed. + QFontCache::instance()->clear(); + } + return i; } |