summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextengine.cpp
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2014-05-18 17:45:45 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-21 15:05:33 +0200
commit4dba08eebf7db7e801ccbf83dec6f17369123f10 (patch)
treeaf309aa2be7bf9b543f23d2db4949bdf4574ff19 /src/gui/text/qtextengine.cpp
parentc9be7743cd754452d89cf7f321889800abf82768 (diff)
Decrease the life time of SpecialData::resolvedFormats
Once LayoutData::items gets cleared, accessing (or re-using) SpecialData::resolvedFormats may lead to a undefined behavior, so clear SpecialData::resolvedFormats right after LayoutData::items. Change-Id: Ib389f0029a0562f5d2837f62f76197510a0db099 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/gui/text/qtextengine.cpp')
-rw-r--r--src/gui/text/qtextengine.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index de7b42604a..0928a22352 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -1414,8 +1414,6 @@ void QTextEngine::invalidate()
freeMemory();
minWidth = 0;
maxWidth = 0;
- if (specialData)
- specialData->resolvedFormats.clear();
resetFontEngineCache();
}
@@ -2357,6 +2355,8 @@ void QTextEngine::freeMemory()
layoutData->haveCharAttributes = false;
layoutData->items.clear();
}
+ if (specialData)
+ specialData->resolvedFormats.clear();
for (int i = 0; i < lines.size(); ++i) {
lines[i].justified = 0;
lines[i].gridfitted = 0;
@@ -2924,13 +2924,12 @@ public:
void QTextEngine::resolveFormats() const
{
- if (!specialData || specialData->formats.isEmpty()
- || !specialData->resolvedFormats.isEmpty())
+ if (!specialData || specialData->formats.isEmpty())
return;
+ Q_ASSERT(specialData->resolvedFormats.isEmpty());
QTextFormatCollection *collection = formatCollection();
- specialData->resolvedFormats.clear();
QVector<QTextCharFormat> resolvedFormats(layoutData->items.count());
QVarLengthArray<int, 64> formatsSortedByStart;