[insertItemWithTitle:...atIndex:] autorelease the return value.

[mouseDown:] when we create the location directory, autorelease it.
In [_locationKey] and [display] remove unneeded checks for popup.
In [copyWithZone:] set the autoenable property before adding items.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@10802 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
FredKiefer 2001-08-30 06:50:04 +00:00
parent 30b68274f6
commit 19a411023b

View file

@ -97,10 +97,6 @@ static NSNotificationCenter *nc;
- (NSString*) _locationKey - (NSString*) _locationKey
{ {
if (_is_beholdenToPopUpButton == YES)
{
return nil; /* Can't save */
}
if (_superMenu == nil) if (_superMenu == nil)
{ {
if ([NSApp mainMenu] == self) if ([NSApp mainMenu] == self)
@ -301,7 +297,7 @@ static NSNotificationCenter *nc;
[self insertItem: anItem atIndex: index]; [self insertItem: anItem atIndex: index];
// For returns sake. // For returns sake.
return anItem; return AUTORELEASE(anItem);
} }
- (void) addItem: (id <NSMenuItem>)newItem - (void) addItem: (id <NSMenuItem>)newItem
@ -964,13 +960,13 @@ static NSNotificationCenter *nc;
unsigned i; unsigned i;
unsigned count = [_items count]; unsigned count = [_items count];
[new setAutoenablesItems: _autoenable];
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
// This works because the copy on NSMenuItem sets the menu to nil!!! // This works because the copy on NSMenuItem sets the menu to nil!!!
[new insertItem: [[_items objectAtIndex: i] copyWithZone: zone] [new insertItem: [[_items objectAtIndex: i] copyWithZone: zone]
atIndex: i]; atIndex: i];
} }
[new setAutoenablesItems: _autoenable];
return new; return new;
} }
@ -1084,25 +1080,18 @@ static NSNotificationCenter *nc;
- (void) display - (void) display
{ {
NSString *key;
if (_changed) if (_changed)
[self sizeToFit]; [self sizeToFit];
if (_is_beholdenToPopUpButton) if (_superMenu && ![self isTornOff])
{ {
[_aWindow orderFront: nil]; // query super menu for position
return;
}
if (_superMenu && ![self isTornOff]) // query super menu for
{ // position
[_aWindow setFrameOrigin: [_superMenu locationForSubmenu: self]]; [_aWindow setFrameOrigin: [_superMenu locationForSubmenu: self]];
_superMenu->_attachedMenu = self; _superMenu->_attachedMenu = self;
} }
else else if (nil != (key = [self _locationKey]))
{
NSString *key = [self _locationKey];
if (key != nil)
{ {
NSUserDefaults *defaults; NSUserDefaults *defaults;
NSDictionary *menuLocations; NSDictionary *menuLocations;
@ -1129,7 +1118,6 @@ static NSNotificationCenter *nc;
[_bWindow setFrameOrigin: aPoint]; [_bWindow setFrameOrigin: aPoint];
} }
} }
}
[_aWindow orderFrontRegardless]; [_aWindow orderFrontRegardless];
@ -1463,12 +1451,11 @@ static NSNotificationCenter *nc;
menuLocations = [[defaults objectForKey: NSMenuLocationsKey] mutableCopy]; menuLocations = [[defaults objectForKey: NSMenuLocationsKey] mutableCopy];
if (menuLocations == nil) if (menuLocations == nil)
{ {
menuLocations = [[NSMutableDictionary alloc] initWithCapacity: 2]; menuLocations = AUTORELEASE([[NSMutableDictionary alloc] initWithCapacity: 2]);
} }
locString = [[menu window] stringWithSavedFrame]; locString = [[menu window] stringWithSavedFrame];
[menuLocations setObject: locString forKey: key]; [menuLocations setObject: locString forKey: key];
[defaults setObject: menuLocations forKey: NSMenuLocationsKey]; [defaults setObject: menuLocations forKey: NSMenuLocationsKey];
RELEASE(menuLocations);
[defaults synchronize]; [defaults synchronize];
} }
} }