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>
This commit is contained in:
parent
c9be7743cd
commit
4dba08eebf
@ -1414,8 +1414,6 @@ void QTextEngine::invalidate()
|
|||||||
freeMemory();
|
freeMemory();
|
||||||
minWidth = 0;
|
minWidth = 0;
|
||||||
maxWidth = 0;
|
maxWidth = 0;
|
||||||
if (specialData)
|
|
||||||
specialData->resolvedFormats.clear();
|
|
||||||
|
|
||||||
resetFontEngineCache();
|
resetFontEngineCache();
|
||||||
}
|
}
|
||||||
@ -2357,6 +2355,8 @@ void QTextEngine::freeMemory()
|
|||||||
layoutData->haveCharAttributes = false;
|
layoutData->haveCharAttributes = false;
|
||||||
layoutData->items.clear();
|
layoutData->items.clear();
|
||||||
}
|
}
|
||||||
|
if (specialData)
|
||||||
|
specialData->resolvedFormats.clear();
|
||||||
for (int i = 0; i < lines.size(); ++i) {
|
for (int i = 0; i < lines.size(); ++i) {
|
||||||
lines[i].justified = 0;
|
lines[i].justified = 0;
|
||||||
lines[i].gridfitted = 0;
|
lines[i].gridfitted = 0;
|
||||||
@ -2924,13 +2924,12 @@ public:
|
|||||||
|
|
||||||
void QTextEngine::resolveFormats() const
|
void QTextEngine::resolveFormats() const
|
||||||
{
|
{
|
||||||
if (!specialData || specialData->formats.isEmpty()
|
if (!specialData || specialData->formats.isEmpty())
|
||||||
|| !specialData->resolvedFormats.isEmpty())
|
|
||||||
return;
|
return;
|
||||||
|
Q_ASSERT(specialData->resolvedFormats.isEmpty());
|
||||||
|
|
||||||
QTextFormatCollection *collection = formatCollection();
|
QTextFormatCollection *collection = formatCollection();
|
||||||
|
|
||||||
specialData->resolvedFormats.clear();
|
|
||||||
QVector<QTextCharFormat> resolvedFormats(layoutData->items.count());
|
QVector<QTextCharFormat> resolvedFormats(layoutData->items.count());
|
||||||
|
|
||||||
QVarLengthArray<int, 64> formatsSortedByStart;
|
QVarLengthArray<int, 64> formatsSortedByStart;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user