summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2012-04-11 08:12:23 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-04-12 05:56:49 (GMT)
commit44c14470e5b28e45c19d6959b114e063cf3f4d83 (patch)
tree735f69894ffa5bddb755dcbb95e1659cd8e28b41 /src
parentd75823432a1f4794c90cc493962366242007012a (diff)
downloadQt-44c14470e5b28e45c19d6959b114e063cf3f4d83.zip
Qt-44c14470e5b28e45c19d6959b114e063cf3f4d83.tar.gz
Qt-44c14470e5b28e45c19d6959b114e063cf3f4d83.tar.bz2
Fix memory leak when drawing text in non-common script
When the fontEngine() cached was updated for new parameters, we would overwrite the cached engine, but not deref the old cached engine, thus it would never be deleted. Change-Id: I3b88698712e468ffa634bd98019a7871662cc363 Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qtextengine.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 3137de6..8fc3176 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1907,12 +1907,17 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix
font.setPixelSize((font.pixelSize() * 2) / 3);
scaledEngine = font.d->engineForScript(script);
}
- feCache.prevFontEngine = engine;
if (engine)
engine->ref.ref();
- feCache.prevScaledFontEngine = scaledEngine;
+ if (feCache.prevFontEngine)
+ releaseCachedFontEngine(feCache.prevFontEngine);
+ feCache.prevFontEngine = engine;
+
if (scaledEngine)
scaledEngine->ref.ref();
+ if (feCache.prevScaledFontEngine)
+ releaseCachedFontEngine(feCache.prevScaledFontEngine);
+ feCache.prevScaledFontEngine = scaledEngine;
feCache.prevScript = script;
feCache.prevPosition = si.position;
feCache.prevLength = length(&si);
@@ -1922,9 +1927,11 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix
engine = feCache.prevFontEngine;
else {
engine = font.d->engineForScript(script);
- feCache.prevFontEngine = engine;
if (engine)
engine->ref.ref();
+ if (feCache.prevFontEngine)
+ releaseCachedFontEngine(feCache.prevFontEngine);
+ feCache.prevFontEngine = engine;
feCache.prevScript = script;
feCache.prevPosition = -1;
feCache.prevLength = -1;