summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfont_p.h
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2013-03-15 01:28:40 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-20 07:02:29 +0100
commit36cb3f3f655a9090c82de609010cbfb88651a0f3 (patch)
treeec892d912da12ce9cbdf96ca3c4952909fa50cd7 /src/gui/text/qfont_p.h
parentef9c3c753dd22e675b334e1b045f93401e1f9df3 (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/gui/text/qfont_p.h')
-rw-r--r--src/gui/text/qfont_p.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/gui/text/qfont_p.h b/src/gui/text/qfont_p.h
index a35896e763..4cbf51d59c 100644
--- a/src/gui/text/qfont_p.h
+++ b/src/gui/text/qfont_p.h
@@ -193,9 +193,8 @@ private:
};
-class QFontCache : public QObject
+class Q_AUTOTEST_EXPORT QFontCache : public QObject
{
- Q_OBJECT
public:
// note: these static functions work on a per-thread basis
static QFontCache *instance();
@@ -205,8 +204,7 @@ public:
~QFontCache();
void clear();
- // universal key structure. QFontEngineDatas and QFontEngines are cached using
- // the same keys
+
struct Key {
Key() : script(0), screen(0) { }
Key(const QFontDef &d, int c, int s = 0)
@@ -245,13 +243,14 @@ public:
typedef QMap<Key,Engine> EngineCache;
EngineCache engineCache;
+ QHash<QFontEngine *, int> engineCacheCount;
QFontEngine *findEngine(const Key &key);
void updateHitCountAndTimeStamp(Engine &value);
void insertEngine(const Key &key, QFontEngine *engine, bool insertMulti = false);
- private:
+private:
void increaseCost(uint cost);
void decreaseCost(uint cost);
void timerEvent(QTimerEvent *event);