summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfont.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@theqtcompany.com>2016-01-21 08:17:21 +0100
committerLiang Qi <liang.qi@theqtcompany.com>2016-01-21 08:17:21 +0100
commit158a3a4159bdc5a49caecd63e021dacbc06cf23c (patch)
treec3ed9aee6cabd46e5e8615b3815b92d32857c4da /src/gui/text/qfont.cpp
parent26ece94a68fb5ae680c5639716b06c4e1ae979a8 (diff)
parent7b2fb038ae4b8b9231ae989ad309b6eca107a858 (diff)
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts: src/corelib/io/qiodevice_p.h src/corelib/kernel/qvariant_p.h src/corelib/tools/qsimd.cpp src/gui/kernel/qguiapplication.cpp tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp Change-Id: I742a093cbb231b282b43e463ec67173e0d29f57a
Diffstat (limited to 'src/gui/text/qfont.cpp')
-rw-r--r--src/gui/text/qfont.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index 7681cc5e51..16e88dad5f 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -2802,6 +2802,10 @@ void QFontCache::insertEngineData(const QFontDef &def, QFontEngineData *engineDa
Q_ASSERT(!engineDataCache.contains(def));
engineData->ref.ref();
+ // Decrease now rather than waiting
+ if (total_cost > min_cost * 2)
+ decreaseCache();
+
engineDataCache.insert(def, engineData);
increaseCost(sizeof(QFontEngineData));
}
@@ -2839,8 +2843,10 @@ void QFontCache::insertEngine(const Key &key, QFontEngine *engine, bool insertMu
key.def.pixelSize, key.def.weight, key.def.style, key.def.fixedPitch);
}
#endif
-
engine->ref.ref();
+ // Decrease now rather than waiting
+ if (total_cost > min_cost * 2)
+ decreaseCache();
Engine data(engine);
data.timestamp = ++current_timestamp;
@@ -2901,7 +2907,11 @@ void QFontCache::timerEvent(QTimerEvent *)
return;
}
+ decreaseCache();
+}
+void QFontCache::decreaseCache()
+{
// go through the cache and count up everything in use
uint in_use_cost = 0;