* Source/NSMenuView.m (heightForItem:, yOriginForItem:):

Accept negative item indicies, which are passed in when
opening the preferences window in TextEdit. Need to investigate
further why that is happening.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37184 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
ericwa 2013-10-03 00:35:27 +00:00
parent 93eeb1101c
commit 2d9baa6c5e
2 changed files with 25 additions and 11 deletions

View file

@ -1,3 +1,10 @@
2013-10-02 Eric Wasylishen <ewasylishen@gmail.com>
* Source/NSMenuView.m (heightForItem:, yOriginForItem:):
Accept negative item indicies, which are passed in when
opening the preferences window in TextEdit. Need to investigate
further why that is happening.
2013-10-02 Eric Wasylishen <ewasylishen@gmail.com> 2013-10-02 Eric Wasylishen <ewasylishen@gmail.com>
* Headers/Additions/GNUstepGUI/GSTheme.h: * Headers/Additions/GNUstepGUI/GSTheme.h:

View file

@ -701,26 +701,33 @@ static float menuBarHeight = 0.0;
return _needsSizing; return _needsSizing;
} }
- (CGFloat) heightForItem: (NSUInteger)idx - (CGFloat) heightForItem: (NSInteger)idx
{ {
NSMenuItemCell *cell = [_itemCells objectAtIndex: idx]; if (idx >= 0)
NSMenuItem *item = [cell menuItem];
if ([item isSeparatorItem])
{ {
return [[GSTheme theme] menuSeparatorHeight]; NSMenuItemCell *cell = [_itemCells objectAtIndex: idx];
NSMenuItem *item = [cell menuItem];
if ([item isSeparatorItem])
{
return [[GSTheme theme] menuSeparatorHeight];
}
} }
return _cellSize.height; return _cellSize.height;
} }
- (CGFloat) yOriginForItem: (NSUInteger)item - (CGFloat) yOriginForItem: (NSInteger)item
{ {
const NSInteger count = [_itemCells count]; const NSInteger count = [_itemCells count];
CGFloat total = 0; CGFloat total = 0;
NSUInteger i = 0;
for (i = (count - 1); i > item ; i--) if (item >= 0)
{ {
total += [self heightForItem: i]; NSInteger i = 0;
for (i = (count - 1); i > item ; i--)
{
total += [self heightForItem: i];
}
} }
return total; return total;
} }