summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2011-01-11 04:10:18 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2011-01-11 04:10:18 (GMT)
commit7393fa902a62e53558ffb56769d31b4d5ba77161 (patch)
tree457c2ce959c110b5d12a8af1886fd88449ce36ba
parent7ca750fad4e74929c9c34a98c19bde37747a9dc5 (diff)
downloadQt-7393fa902a62e53558ffb56769d31b4d5ba77161.zip
Qt-7393fa902a62e53558ffb56769d31b4d5ba77161.tar.gz
Qt-7393fa902a62e53558ffb56769d31b4d5ba77161.tar.bz2
Don't crash if cursor at the end.
77cba04c2 assumed a level of bounds checking in QTextLayout that does not exist. Task-number: qtbug-15818 Reviewed-by: Michael Brasser
-rw-r--r--src/gui/widgets/qlinecontrol.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index 12607c1..9abbfac 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -541,7 +541,10 @@ void QLineControl::draw(QPainter *painter, const QPoint &offset, const QRect &cl
*/
void QLineControl::selectWordAtPos(int cursor)
{
- int c = m_textLayout.previousCursorPosition(cursor+1, QTextLayout::SkipWords);
+ int next = cursor + 1;
+ if(next > end())
+ --next;
+ int c = m_textLayout.previousCursorPosition(next, QTextLayout::SkipWords);
moveCursor(c, false);
// ## text layout should support end of words.
int end = m_textLayout.nextCursorPosition(c, QTextLayout::SkipWords);