summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-02-22 14:49:34 (GMT)
committerJiang Jiang <jiang.jiang@nokia.com>2011-07-11 15:05:42 (GMT)
commit5f2b6dd2a50275bc05ae5d7e9dd8902d6d49d9df (patch)
tree6dd9614fe87bad0ed906d320933825b1cac8970b /src
parentc4b5e186c7718f0a03d6ed529f546e7debfbcf86 (diff)
downloadQt-5f2b6dd2a50275bc05ae5d7e9dd8902d6d49d9df.zip
Qt-5f2b6dd2a50275bc05ae5d7e9dd8902d6d49d9df.tar.gz
Qt-5f2b6dd2a50275bc05ae5d7e9dd8902d6d49d9df.tar.bz2
Keep reference count for cached font engines in QTextEngine
So that if these font engines are deallocated elsewhere (by QFontCache for instance), we can still access them in QTextEngine. Task-number: QTBUG-17603 Reviewed-by: Eskil (cherry picked from commit 6e23fb69e441871829765ff512e90fed17b6798d)
Diffstat (limited to 'src')
-rw-r--r--src/gui/text/qtextengine.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index 03717dc..6322245 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1385,6 +1385,15 @@ void QTextEngine::shape(int item) const
}
}
+static inline void releaseCachedFontEngine(QFontEngine *fontEngine)
+{
+ if (fontEngine) {
+ fontEngine->ref.deref();
+ if (fontEngine->cache_count == 0 && fontEngine->ref == 0)
+ delete fontEngine;
+ }
+}
+
void QTextEngine::invalidate()
{
freeMemory();
@@ -1392,6 +1401,9 @@ void QTextEngine::invalidate()
maxWidth = 0;
if (specialData)
specialData->resolvedFormatIndices.clear();
+
+ releaseCachedFontEngine(feCache.prevFontEngine);
+ releaseCachedFontEngine(feCache.prevScaledFontEngine);
feCache.reset();
}
@@ -1824,7 +1836,9 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix
scaledEngine = font.d->engineForScript(script);
}
feCache.prevFontEngine = engine;
+ engine->ref.ref();
feCache.prevScaledFontEngine = scaledEngine;
+ scaledEngine->ref.ref();
feCache.prevScript = script;
feCache.prevPosition = si.position;
feCache.prevLength = length(&si);
@@ -1835,6 +1849,7 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix
else {
engine = font.d->engineForScript(script);
feCache.prevFontEngine = engine;
+ engine->ref.ref();
feCache.prevScript = script;
feCache.prevPosition = -1;
feCache.prevLength = -1;