Fix crash with invalid pre-edit position.

Ensure the script item position is within the bounds of the text block
when adjusted to compensate for pre-edit text.

Change-Id: I2c745bf08afc0d9bc3aba27c24c2a123af017dc6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
This commit is contained in:
Andrew den Exter 2012-04-04 15:34:09 +10:00 committed by Qt by Nokia
parent efdadbb3d6
commit 5a02c2115c

View File

@ -2185,7 +2185,7 @@ int QTextEngine::formatIndex(const QScriptItem *si) const
int pos = si->position;
if (specialData && si->position >= specialData->preeditPosition) {
if (si->position < specialData->preeditPosition + specialData->preeditText.length())
pos = qMax(specialData->preeditPosition - 1, 0);
pos = qMax(qMin(block.length(), specialData->preeditPosition) - 1, 0);
else
pos -= specialData->preeditText.length();
}