mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-29 20:17:38 +00:00
Undid the tracking of changes for the menu item. Changed [dealloc]
to not call clean up methods as these caused segmentation faults in GNUMail. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@17696 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
310ac897be
commit
a8a470ff28
1 changed files with 13 additions and 25 deletions
|
@ -85,27 +85,18 @@ static NSImage *_pbc_image[2];
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
[self selectItem: nil];
|
||||
[self setMenu: nil];
|
||||
/*
|
||||
* We don't use methods here to clean up the selected item, the menu
|
||||
* item and the menu as these methods internally update the menu,
|
||||
* which tries to access the target of the menu item (or of this cell).
|
||||
* When the popup is relases this target may already have been freed,
|
||||
* so the local reference to it is invalid and will result in a
|
||||
* segmentation fault.
|
||||
*/
|
||||
_selectedItem = nil;
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
/*
|
||||
* Notification Method
|
||||
*/
|
||||
|
||||
- (void) itemChanged: (NSNotification*)notification
|
||||
{
|
||||
int index = [[[notification userInfo] objectForKey: @"NSMenuItemIndex"]
|
||||
intValue];
|
||||
id <NSMenuItem> item = [self itemAtIndex: index];
|
||||
|
||||
if (item == _menuItem)
|
||||
{
|
||||
[[self controlView] setNeedsDisplay: YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) setMenu: (NSMenu *)menu
|
||||
{
|
||||
if (_menu == menu)
|
||||
|
@ -116,23 +107,20 @@ static NSImage *_pbc_image[2];
|
|||
if (_menu != nil)
|
||||
{
|
||||
[_menu _setOwnedByPopUp: nil];
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self
|
||||
name: nil
|
||||
object: _menu];
|
||||
}
|
||||
ASSIGN(_menu, menu);
|
||||
if (_menu != nil)
|
||||
{
|
||||
[_menu _setOwnedByPopUp: self];
|
||||
[[NSNotificationCenter defaultCenter] addObserver: self
|
||||
selector: @selector(itemChanged:)
|
||||
name: NSMenuDidChangeItemNotification
|
||||
object: _menu];
|
||||
/* We need to set the menu view so we trigger the special case
|
||||
* popupbutton code in super class NSMenuItemCell
|
||||
*/
|
||||
[self setMenuView: [_menu menuRepresentation]];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setMenuView: nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSMenu *) menu
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue