summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2011-09-09 12:31:39 (GMT)
committerJiang Jiang <jiang.jiang@nokia.com>2011-09-16 11:01:24 (GMT)
commit8935a84e18804c7ff4b7336e3cfdf1cd558eaf1c (patch)
treeebed5bf2916a99a976c5f42c9de41cc5d435fa7c /src/gui/text
parent9463ba63bc7e41a1d6aa320aced392843e31b160 (diff)
downloadQt-8935a84e18804c7ff4b7336e3cfdf1cd558eaf1c.zip
Qt-8935a84e18804c7ff4b7336e3cfdf1cd558eaf1c.tar.gz
Qt-8935a84e18804c7ff4b7336e3cfdf1cd558eaf1c.tar.bz2
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
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qtextengine.cpp12
-rw-r--r--src/gui/text/qtextengine_p.h1
-rw-r--r--src/gui/text/qtextlayout.cpp4
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<int> &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<FormatRange> &formatList)
}
if (d->block.docHandle())
d->block.docHandle()->documentChange(d->block.position(), d->block.length());
- d->feCache.reset();
+ d->resetFontEngineCache();
}
/*!