Re: Disappointed by GNUstep
Sergei Golovin <[email protected]> Tue, 08 Feb 2022 08:11:20 +0400
| Newsgroups | gmane.comp.lib.gnustep.devel |
|---|---|
| Message-ID | <fed0cd0853e2b88fba3721431fc7ce97@iamhere> |
On 2022-02-08 07:16:44 +0400 Sergei Golovin <[email protected]> wrote: > On 2022-02-08 02:49:26 +0400 Wolfgang Lux <[email protected]> > wrote: > >>> The attached patch changes the -[dealloc] to do the code chunk >>> equivalent >>> to -[setMenu:nil] >>> avoiding that -[NSPopUpButtonCell synchronizeTitleAndSelectedItem] >>> and following. > > >> didn't have time to look at your second message earlier. >> I like the idea of avoiding the call to setMenu: altogether. That >> said, >> there is a little problem with your patch: It lets the menu leak. >> There >> should be a DESTROY(_menu) or RELEASE(_menu) statement after removing >> the observer. > > _menu is owned by a superclass and released there. See -[NSCell > dealloc]. Oh, :-) I was wrong. -- SG <gtam_segfault_on_quit_bug.patch>
gtam_segfault_on_quit_bug.patch
(text/x-patch, 780 B)
diff --git a/Source/NSPopUpButtonCell.m b/Source/NSPopUpButtonCell.m
index a60a0ca4d..499f1df89 100644
--- a/Source/NSPopUpButtonCell.m
+++ b/Source/NSPopUpButtonCell.m
@@ -138,6 +138,7 @@ static NSImage *_pbc_image[5];
- (void) dealloc
{
+ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
/*
* The popup must be closed here, just in case the cell goes away
* while the popup is still displayed. In that case the notification
@@ -150,7 +151,11 @@ static NSImage *_pbc_image[5];
if (_menu != nil)
{
- [self setMenu: nil];
+ [_menu _setOwnedByPopUp: nil];
+ [nc removeObserver: self
+ name: nil
+ object: _menu];
+ RELEASE(_menu);
}
_selectedItem = nil;
[super dealloc];