diff options
Diffstat (limited to 'src/gui/text/qfont.cpp')
-rw-r--r-- | src/gui/text/qfont.cpp | 12 |
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; |