[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdegraphics/kolourpaint/tools/selection/text
From:       Clarence Dang <dang () kde ! org>
Date:       2007-08-22 13:07:47
Message-ID: 1187788067.065835.22567.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 703411 by dang:

Moving the cursor when the text selection has no content (and therefore, no textLines) should not crash.


 M  +15 -0     kpToolText_CursorCalc.cpp  


--- trunk/KDE/kdegraphics/kolourpaint/tools/selection/text/kpToolText_CursorCalc.cpp #703410:703411
@@ -72,6 +72,9 @@
 bool kpToolText::CursorIsAtEnd (const QList <QString> &textLines,
     int cursorRow, int cursorCol)
 {
+    if (textLines.isEmpty ())
+        return (cursorRow == 0 && cursorCol == 0);
+        
     return (cursorRow == (int) textLines.size () - 1 &&
             cursorCol == (int) textLines [cursorRow].length ());
 }
@@ -81,6 +84,9 @@
 void kpToolText::MoveCursorLeft (const QList <QString> &textLines,
     int *cursorRow, int *cursorCol)
 {
+    if (textLines.isEmpty ())
+        return;
+        
     (*cursorCol)--;
 
     if (*cursorCol < 0)
@@ -100,6 +106,9 @@
 void kpToolText::MoveCursorRight (const QList <QString> &textLines,
     int *cursorRow, int *cursorCol)
 {
+    if (textLines.isEmpty ())
+        return;
+        
     (*cursorCol)++;
 
     if (*cursorCol > (int) textLines [*cursorRow].length ())
@@ -122,6 +131,9 @@
 int kpToolText::MoveCursorToWordStart (const QList <QString> &textLines,
     int *cursorRow, int *cursorCol)
 {
+    if (textLines.isEmpty ())
+        return 0;
+
     int numMoves = 0;
 
 #define IS_ON_ANCHOR()                                            \
@@ -165,6 +177,9 @@
 int kpToolText::MoveCursorToNextWordStart (const QList <QString> &textLines,
     int *cursorRow, int *cursorCol)
 {
+    if (textLines.isEmpty ())
+        return 0;
+        
     int numMoves = 0;
 
 #define IS_AT_END() CursorIsAtEnd (textLines, *cursorRow, *cursorCol)
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic