Author: mordante
Date: Wed Aug 27 00:20:53 2008
New Revision: 29007

URL: http://svn.gna.org/viewcvs/wesnoth?rev=29007&view=rev
Log:
Fixed a crash when moving and selecting.

Then moving the cursor in the textbox the bounds check didn't look at
the length of the selection and the cursor could be placed out of
bounds. Now properly check whether the new position is within bounds.

Modified:
    trunk/src/gui/widgets/text.cpp

Modified: trunk/src/gui/widgets/text.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/text.cpp?rev=29007&r1=29006&r2=29007&view=diff
==============================================================================
--- trunk/src/gui/widgets/text.cpp (original)
+++ trunk/src/gui/widgets/text.cpp Wed Aug 27 00:20:53 2008
@@ -310,9 +310,9 @@
        DBG_G_E << "Text: key press: left arrow.\n";
 
        handled = true;
-       if(selection_start_) {
-               set_cursor(
-                       selection_start_ - 1 + selection_length_, modifier & 
KMOD_SHIFT);
+       const int offset = selection_start_ - 1 + selection_length_;
+       if(offset >= 0) {
+               set_cursor(offset, modifier & KMOD_SHIFT);
        }
 }
 
@@ -322,9 +322,9 @@
        DBG_G_E << "Text: key press: right arrow.\n";
 
        handled = true;
-       if(selection_start_ < text_.size()) {
-               set_cursor(
-                       selection_start_ + 1 + selection_length_, modifier & 
KMOD_SHIFT);
+       const int offset = selection_start_ + 1 + selection_length_;
+       if(offset <= text_.size()) {
+               set_cursor(offset, modifier & KMOD_SHIFT);
        }
 }
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to