diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2013-03-15 01:28:40 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-20 07:02:29 +0100 |
commit | 36cb3f3f655a9090c82de609010cbfb88651a0f3 (patch) | |
tree | ec892d912da12ce9cbdf96ca3c4952909fa50cd7 /src/plugins | |
parent | ef9c3c753dd22e675b334e1b045f93401e1f9df3 (diff) |
Fix the font engines leaking
1. when there were some engines with ref > 1 in the cache, prior to calling
QFontDatabase::{add,remove}ApplicationFont()/removeAllApplicationFonts()
(QFontCache::clear() has never decreased engine's cache_count);
2. when the QFontEngineData's engine is not in cache i.e. the Box or Test font engine
(~QFontEngineData() didn't free engines it keeps).
Instead of using the font engine's (external) "cache_count" counter,
QFontCache now references a given font engine every time it is inserted to
the cache and dereferences exactly that number of times in clear().
Change-Id: I87677ebd24c1f4a81a53526f2e726e596b043c61
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/windows/qwindowsfontdatabase.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index 2fa691347d..c59b0edf78 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -1097,11 +1097,11 @@ QFontEngine *QWindowsFontDatabase::fontEngine(const QByteArray &fontData, qreal if (request.family != fontEngine->fontDef.family) { qWarning("%s: Failed to load font. Got fallback instead: %s", __FUNCTION__, qPrintable(fontEngine->fontDef.family)); - if (fontEngine->cache_count == 0 && fontEngine->ref.load() == 0) + if (fontEngine->ref.load() == 0) delete fontEngine; fontEngine = 0; } else { - Q_ASSERT(fontEngine->cache_count == 0 && fontEngine->ref.load() == 0); + Q_ASSERT(fontEngine->ref.load() == 0); // Override the generated font name static_cast<QWindowsFontEngine *>(fontEngine)->setUniqueFamilyName(uniqueFamilyName); |