Fix off-by-one error in binary search

This one-line change makes the binary search in QTextEngine::findItem
behave consistently with the linear search that it replaced in commit
acf678e57ed088f3e56a551cac6c7c3322005750. The new behavior seems to
cause crashes in kword (and perhaps other applications) by triggering a
logClusters assert, although I have been unable to create a unit test
that reproduces this.

Task-number: QTBUG-17209
Done-by: Dr. Robert Marmorstein <robert@narnia.homeunix.com>
Change-Id: I68b79f024e9836e1cc8b0f3514889120541eb2ea
Reviewed-on: http://codereview.qt.nokia.com/2343
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jiang Jiang <jiang.jiang@nokia.com>
This commit is contained in:
Jiang Jiang 2011-07-28 14:51:54 +02:00 committed by Qt by Nokia
parent 78cf553469
commit 487583459e

View File

@ -1632,7 +1632,7 @@ bool QTextEngine::isRightToLeft() const
int QTextEngine::findItem(int strPos) const
{
itemize();
int left = 0;
int left = 1;
int right = layoutData->items.size()-1;
while(left <= right) {
int middle = ((right-left)/2)+left;