Author: dpsimons
Date: Fri Sep 11 00:41:19 2015
New Revision: 38981

URL: http://svn.gna.org/viewcvs/gnustep?rev=38981&view=rev
Log:
fix NSLayoutManager issue when selection overlaps replaced range in an unusual 
way

Modified:
    libs/gui/branches/gnustep_testplant_branch/ChangeLog
    libs/gui/branches/gnustep_testplant_branch/Source/NSLayoutManager.m

Modified: libs/gui/branches/gnustep_testplant_branch/ChangeLog
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/ChangeLog?rev=38981&r1=38980&r2=38981&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/ChangeLog        (original)
+++ libs/gui/branches/gnustep_testplant_branch/ChangeLog        Fri Sep 11 
00:41:19 2015
@@ -1,3 +1,9 @@
+2015-09-10  Doug Simons <[email protected]> and Paul Landers 
<[email protected]>
+
+       * Source/NSLayoutManager.m: Fix a bug that would try to adjust
+       the length of the selected range to a negative number, leading
+       to an exception and eventual crashes.
+       
 2015-09-08  Doug Simons <[email protected]>
 
        * Source/NSOutlineView.m: Update expandItem:expandChildren:

Modified: libs/gui/branches/gnustep_testplant_branch/Source/NSLayoutManager.m
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/NSLayoutManager.m?rev=38981&r1=38980&r2=38981&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/NSLayoutManager.m 
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/NSLayoutManager.m Fri Sep 
11 00:41:19 2015
@@ -2639,7 +2639,7 @@
 
       if (!layout_char)
        new_last_glyph = 0;
-      else if (layout_char >= [_textStorage length])
+      else if (layout_char == [_textStorage length])
        new_last_glyph = [self numberOfGlyphs];
       else
        new_last_glyph = [self glyphRangeForCharacterRange: 
NSMakeRange(layout_char, 1)
@@ -2917,7 +2917,7 @@
 (of selection, wrt range, before change)
       --------------------------
       after     after     location += lengthChange;
-      in        after     length = 
NSMaxRange(sel)-NSMaxRange(range)-lengthChange; location=NSMaxRange(range);
+      in        after     length = 
NSMaxRange(sel)-(NSMaxRange(range)-lengthChange); location=NSMaxRange(range);
       in        in        length = 0; location=NSMaxRange(range);
       before    after     length += lengthChange;
       before    in        length = range.location-location;
@@ -2939,7 +2939,7 @@
        {
          if (NSMaxRange(_selected_range) > NSMaxRange(range) - lengthChange)
            { /* in after */
-             newRange.length = NSMaxRange(_selected_range) - NSMaxRange(range) 
- lengthChange;
+             newRange.length = NSMaxRange(_selected_range) - 
(NSMaxRange(range) - lengthChange);
              newRange.location = NSMaxRange(range);
            }
          else
@@ -2959,6 +2959,10 @@
       else
        { /* before before */
        }
+       /* sanity check */
+       if (NSMaxRange(newRange) > [_textStorage length]) 
+               newRange = NSMakeRange(MIN(range.location, [_textStorage 
length]), 0);
+               
 
       /* If there are text views attached to us, let them handle the
       change. */


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to