mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-29 19:07:38 +00:00
Make sure menu views get cleaned up properly.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20122 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
41f8cfab6b
commit
54da49bd72
3 changed files with 31 additions and 14 deletions
|
@ -300,6 +300,7 @@ static NSNotificationCenter *nc;
|
|||
RELEASE(_notifications);
|
||||
RELEASE(_title);
|
||||
RELEASE(_items);
|
||||
[_view setMenu: nil];
|
||||
RELEASE(_view);
|
||||
RELEASE(_aWindow);
|
||||
RELEASE(_bWindow);
|
||||
|
@ -312,14 +313,14 @@ static NSNotificationCenter *nc;
|
|||
*/
|
||||
- (id) initWithTitle: (NSString*)aTitle
|
||||
{
|
||||
NSView *contentView;
|
||||
NSMenuView *menuRep;
|
||||
|
||||
[super init];
|
||||
|
||||
// Keep the title.
|
||||
ASSIGN(_title, aTitle);
|
||||
|
||||
// Create an array to store out menu items.
|
||||
// Create an array to store our menu items.
|
||||
_items = [[NSMutableArray alloc] init];
|
||||
|
||||
_changedMessagesEnabled = YES;
|
||||
|
@ -340,11 +341,9 @@ static NSNotificationCenter *nc;
|
|||
[_bWindow setLevel: NSPopUpMenuWindowLevel];
|
||||
|
||||
// Create a NSMenuView to draw our menu items.
|
||||
_view = [[NSMenuView alloc] initWithFrame: NSZeroRect];
|
||||
[_view setMenu: self];
|
||||
|
||||
contentView = [_aWindow contentView];
|
||||
[contentView addSubview: _view];
|
||||
menuRep = [[NSMenuView alloc] initWithFrame: NSZeroRect];
|
||||
[self setMenuRepresentation: menuRep];
|
||||
RELEASE(menuRep);
|
||||
|
||||
/* Set up the notification to start the process of redisplaying
|
||||
the menus where the user left them the last time.
|
||||
|
@ -940,9 +939,18 @@ static NSNotificationCenter *nc;
|
|||
return;
|
||||
}
|
||||
|
||||
// remove the old representation
|
||||
if (_view == menuRep)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
contentView = [_aWindow contentView];
|
||||
[contentView removeSubview: _view];
|
||||
if (_view != nil)
|
||||
{
|
||||
// remove the old representation
|
||||
[contentView removeSubview: _view];
|
||||
[_view setMenu: nil];
|
||||
}
|
||||
|
||||
ASSIGN(_view, menuRep);
|
||||
[_view setMenu: self];
|
||||
|
|
|
@ -185,12 +185,12 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
|||
selector: @selector(itemRemoved:)
|
||||
name: NSMenuDidRemoveItemNotification
|
||||
object: _attachedMenu];
|
||||
|
||||
// Force menu view's layout to be recalculated.
|
||||
[self setNeedsSizing: YES];
|
||||
|
||||
[self update];
|
||||
}
|
||||
|
||||
// Force menu view's layout to be recalculated.
|
||||
[self setNeedsSizing: YES];
|
||||
|
||||
[self update];
|
||||
}
|
||||
|
||||
- (NSMenu*) menu
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue