From 8935a84e18804c7ff4b7336e3cfdf1cd558eaf1c Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Fri, 9 Sep 2011 14:31:39 +0200 Subject: Release font engine refcount when done using it in QTextEngine 5f2b6dd2a50275bc05ae5d7e9dd8902d6d49d9df increased refcounts for font engines in QTextEngine cache, we need to decrease them when the QTextEngine is deallocated. Task-number: QTBUG-21222 Reviewed-by: Eskil --- src/gui/text/qtextengine.cpp | 12 +++++++++--- src/gui/text/qtextengine_p.h | 1 + src/gui/text/qtextlayout.cpp | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index a0e1751..a1b0cb0 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1387,6 +1387,7 @@ QTextEngine::~QTextEngine() if (!stackEngine) delete layoutData; delete specialData; + resetFontEngineCache(); } const HB_CharAttributes *QTextEngine::attributes() const @@ -1447,6 +1448,13 @@ static inline void releaseCachedFontEngine(QFontEngine *fontEngine) } } +void QTextEngine::resetFontEngineCache() +{ + releaseCachedFontEngine(feCache.prevFontEngine); + releaseCachedFontEngine(feCache.prevScaledFontEngine); + feCache.reset(); +} + void QTextEngine::invalidate() { freeMemory(); @@ -1455,9 +1463,7 @@ void QTextEngine::invalidate() if (specialData) specialData->resolvedFormatIndices.clear(); - releaseCachedFontEngine(feCache.prevFontEngine); - releaseCachedFontEngine(feCache.prevScaledFontEngine); - feCache.reset(); + resetFontEngineCache(); } void QTextEngine::clearLineData() diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index 0a86886..9362022 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -629,6 +629,7 @@ public: int lineNumberForTextPosition(int pos); int positionAfterVisualMovement(int oldPos, QTextCursor::MoveOperation op); void insertionPointsForLine(int lineNum, QVector &insertionPoints); + void resetFontEngineCache(); private: void setBoundary(int strPos) const; diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index c92e15b..d0c1a0e 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -375,7 +375,7 @@ QTextLayout::~QTextLayout() void QTextLayout::setFont(const QFont &font) { d->fnt = font; - d->feCache.reset(); + d->resetFontEngineCache(); } /*! @@ -515,7 +515,7 @@ void QTextLayout::setAdditionalFormats(const QList &formatList) } if (d->block.docHandle()) d->block.docHandle()->documentChange(d->block.position(), d->block.length()); - d->feCache.reset(); + d->resetFontEngineCache(); } /*! -- cgit v0.12