[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Fix, GSSimpleLayoutManager
From: |
Georg Fleischmann |
Subject: |
Fix, GSSimpleLayoutManager |
Date: |
Fri, 17 May 2002 18:49:22 GMT |
Hi,
here are some small fixes for GSSimpleLayoutManager which check the array
count of _lineLayoutInformation before accessing the array.
The modifications allow (for example) a text box of zero size without getting
an exception.
Georg
2002-05-17 Georg Fleischmann
* gui/Source/GSSimpleLayoutManager.m
[GSSimpleLayoutManager -lineLayoutIndexForPoint:]:
cast the count of _lineLayoutInformation to integer in MAX().
test if max is zero.
[GSSimpleLayoutManager -glyphRangeForLineLayoutRange:]:
test if count of _lineLayoutInformation is zero
[GSSimpleLayoutManager -drawLinesInLineRange:]:
test if count of _lineLayoutInformation is inside range
*** gui/Source/GSSimpleLayoutManager.m.old Tue Mar 26 20:00:18 2002
--- gui/Source/GSSimpleLayoutManager.m Fri May 17 20:27:44 2002
***************
*** 542,553 ****
{
int i;
int min = 0;
! int max = MAX(0, [_lineLayoutInformation count] - 1);
float y = point.y;
! float fmin = NSMinY([[_lineLayoutInformation objectAtIndex: 0]
lineFragmentRect]);
! float fmax = NSMaxY([[_lineLayoutInformation lastObject] lineFragmentRect]);
NSRect rect;
if (y >= fmax)
return max;
--- 542,559 ----
{
int i;
int min = 0;
! int max = MAX(0, (int)[_lineLayoutInformation count] - 1);
float y = point.y;
! float fmin;
! float fmax;
NSRect rect;
+ if (!max)
+ return 0;
+
+ fmin = NSMinY([[_lineLayoutInformation objectAtIndex: 0] lineFragmentRect]);
+ fmax = NSMaxY([[_lineLayoutInformation lastObject] lineFragmentRect]);
+
if (y >= fmax)
return max;
***************
*** 636,641 ****
--- 642,649 ----
unsigned startIndex;
unsigned endIndex;
+ if ([_lineLayoutInformation count] == 0)
+ return NSMakeRange(0, 0);
if (startLine >= [_lineLayoutInformation count])
currentInfo = [_lineLayoutInformation lastObject];
else
***************
*** 727,736 ****
// relies on _lineLayoutInformation
- (void) drawLinesInLineRange: (NSRange)aRange;
{
! NSArray *linesToDraw = [_lineLayoutInformation subarrayWithRange: aRange];
NSEnumerator *lineEnum;
_GNULineLayoutInfo *currentInfo;
for ((lineEnum = [linesToDraw objectEnumerator]);
(currentInfo = [lineEnum nextObject]);)
{
--- 735,747 ----
// relies on _lineLayoutInformation
- (void) drawLinesInLineRange: (NSRange)aRange;
{
! NSArray *linesToDraw;
NSEnumerator *lineEnum;
_GNULineLayoutInfo *currentInfo;
+ if ([_lineLayoutInformation count] < aRange.location+aRange.length)
+ return;
+ linesToDraw = [_lineLayoutInformation subarrayWithRange: aRange];
for ((lineEnum = [linesToDraw objectEnumerator]);
(currentInfo = [lineEnum nextObject]);)
{
- Fix, GSSimpleLayoutManager,
Georg Fleischmann <=