From 36cb3f3f655a9090c82de609010cbfb88651a0f3 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Fri, 15 Mar 2013 01:28:40 +0200 Subject: 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 --- src/gui/text/qrawfont.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/gui/text/qrawfont.cpp') diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index 5781b49eab..f52b46eeae 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -738,8 +738,7 @@ void QRawFont::setPixelSize(qreal pixelSize) if (d->fontEngine != 0) d->fontEngine->ref.ref(); - oldFontEngine->ref.deref(); - if (oldFontEngine->cache_count == 0 && oldFontEngine->ref.load() == 0) + if (!oldFontEngine->ref.deref()) delete oldFontEngine; } @@ -750,8 +749,7 @@ void QRawFontPrivate::cleanUp() { platformCleanUp(); if (fontEngine != 0) { - fontEngine->ref.deref(); - if (fontEngine->cache_count == 0 && fontEngine->ref.load() == 0) + if (!fontEngine->ref.deref()) delete fontEngine; fontEngine = 0; } -- cgit v1.2.3