mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 08:30:59 +00:00
* Source/NSMenuView.m (-heightForItem:): Use
-menuItemCellForItemAtIndex: to protect against an index being to big. This happens when the menu does not send notifications and a non-existing item gets highlighted. * Source/NSMenuView.m (-menuItemCellForItemAtIndex:): Protect against negative index values. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37279 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
35b547f964
commit
56803c6c14
2 changed files with 16 additions and 5 deletions
|
@ -1,3 +1,12 @@
|
|||
2013-10-26 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSMenuView.m (-heightForItem:): Use
|
||||
-menuItemCellForItemAtIndex: to protect against an index being to
|
||||
big. This happens when the menu does not send notifications and a
|
||||
non-existing item gets highlighted.
|
||||
* Source/NSMenuView.m (-menuItemCellForItemAtIndex:): Protect
|
||||
against negative index values.
|
||||
|
||||
2013-10-20 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSBitmapImageRep+PNG.m: Better cleanup on error.
|
||||
|
|
|
@ -444,7 +444,7 @@ static float menuBarHeight = 0.0;
|
|||
|
||||
- (NSMenuItemCell*) menuItemCellForItemAtIndex: (NSInteger)index
|
||||
{
|
||||
if (index < [_itemCells count])
|
||||
if ((index >= 0) && (index < [_itemCells count]))
|
||||
return [_itemCells objectAtIndex: index];
|
||||
else
|
||||
return nil;
|
||||
|
@ -703,9 +703,10 @@ static float menuBarHeight = 0.0;
|
|||
|
||||
- (CGFloat) heightForItem: (NSInteger)idx
|
||||
{
|
||||
if (idx >= 0)
|
||||
NSMenuItemCell *cell = [self menuItemCellForItemAtIndex: idx];
|
||||
|
||||
if (cell != nil)
|
||||
{
|
||||
NSMenuItemCell *cell = [_itemCells objectAtIndex: idx];
|
||||
NSMenuItem *item = [cell menuItem];
|
||||
|
||||
if ([item isSeparatorItem])
|
||||
|
@ -724,7 +725,7 @@ static float menuBarHeight = 0.0;
|
|||
if (item >= 0)
|
||||
{
|
||||
NSInteger i = 0;
|
||||
for (i = (count - 1); i > item ; i--)
|
||||
for (i = (count - 1); i > item; i--)
|
||||
{
|
||||
total += [self heightForItem: i];
|
||||
}
|
||||
|
@ -736,7 +737,8 @@ static float menuBarHeight = 0.0;
|
|||
{
|
||||
CGFloat total = 0;
|
||||
NSUInteger i = 0;
|
||||
for (i = 0; i<[_itemCells count]; i++)
|
||||
|
||||
for (i = 0; i < [_itemCells count]; i++)
|
||||
{
|
||||
total += [self heightForItem: i];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue