Fixed an NSRangeException that would get raised in drawRect: when we have an empty content array by explicitly casting values to int in the MIN macro.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@36580 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Frank Le Grand 2013-04-24 16:47:43 +00:00
parent 6f9a0ad102
commit 588eab8526
2 changed files with 11 additions and 7 deletions

View file

@ -1,4 +1,8 @@
2013-04-22 Doug Simons <doug.simons@testplant.com>
2013-04-24 Frank Le Grand <frank.legrand@testplant.com>
* Source\NSCollectionView.m: Fixed an NSRangeException that would get raised in drawRect:
when we have an empty content array by explicitly casting values to int in the MIN macro.
2013-04-22 Doug Simons <doug.simons@testplant.com>
* Source/NSTextFieldCell.m: Add support for NSLineBreakByTruncatingHead/Tail/Middle
line break modes.

View file

@ -188,8 +188,8 @@ static NSString *placeholderItem = nil;
NSSize size = dirtyRect.size;
NSPoint oppositeOrigin = NSMakePoint (origin.x + size.width, origin.y + size.height);
int firstIndexInRect = MAX(0, [self _indexAtPoint:origin]);
int lastIndexInRect = MIN([_items count] - 1, [self _indexAtPoint:oppositeOrigin]);
int firstIndexInRect = MAX(0, (int)[self _indexAtPoint:origin]);
int lastIndexInRect = MIN((int)([_items count] - 1), (int)[self _indexAtPoint:oppositeOrigin]);
int index = firstIndexInRect;
for (; index <= lastIndexInRect; index++)
@ -433,7 +433,7 @@ static NSString *placeholderItem = nil;
long count = (long)[_items count];
if (_maxNumberOfColumns > 0 && _maxNumberOfRows > 0)
count = MIN(count, _maxNumberOfColumns * _maxNumberOfRows);
count = MIN((int)count, (int)(_maxNumberOfColumns * _maxNumberOfRows));
float x = _horizontalMargin;
float y = -_itemSize.height;
@ -486,8 +486,8 @@ static NSString *placeholderItem = nil;
- (NSRect) _frameForRowsAroundItemAtIndex: (NSUInteger)theIndex
{
NSRect itemRowFrame = [self _frameForRowOfItemAtIndex:theIndex];
float y = MAX (0, itemRowFrame.origin.y - itemRowFrame.size.height);
float height = MIN (itemRowFrame.size.height * 3, [self bounds].size.height);
float y = MAX (0, (int)(itemRowFrame.origin.y - itemRowFrame.size.height));
float height = MIN ((int)(itemRowFrame.size.height * 3), (int)([self bounds].size.height));
NSRect rowsRect = NSMakeRect(0, y, itemRowFrame.size.width, height);
return rowsRect;
}
@ -881,7 +881,7 @@ static NSString *placeholderItem = nil;
direction: (int)aDirection
expand: (BOOL)shouldExpand
{
anIndex = MIN (MAX (anIndex, 0), [_items count] - 1);
anIndex = MIN ((int)(MAX (anIndex, 0)), (int)([_items count] - 1));
if (_allowsMultipleSelection && shouldExpand)
{