From 7393fa902a62e53558ffb56769d31b4d5ba77161 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 11 Jan 2011 14:10:18 +1000 Subject: 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 --- src/gui/widgets/qlinecontrol.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); -- cgit v0.12