[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Fix NSMenu retainCount problem

From: Quentin Mathé
Subject: Re: [PATCH] Fix NSMenu retainCount problem
Date: Fri, 6 Feb 2004 00:13:02 +0100

Le 5 févr. 04, à 22:37, Fred Kiefer a écrit :

Quentin Mathé wrote:

I did spend some time on this problem and I would like to only accept half of your patches. First I have to admit, that I was wrong with the notification center. There everythign seems to be ok. On the other hand I was right that the problem should also occure if you only create a menu and released it again. And this gets solved by your patch on NSMenuView, which really doesnt do any harm as the GSTitleView never uses the menu, it only refers to its owner ivar.


In the second case you may have been mislead by the notification still hanging around. When trying to investigate memory leaks one cannot be to carefull to wrap extra layers of auto release pools around the operations in question. Only when the count is still wrong on the highest level, than there is an actual problem.

I think it's the case (the count is wrong at the highest level, here NSMenu) or I'm not understanding what you have said.

So if you agree, I will apply the second patch and also some of the more verbose error messages you did add to NSMenu. The other changes would only make the code in NSMenu harder to read and give no benefit I can see.

ok, but...

Here is an example :
with Cocoa, the code below release and dealloc the menu variable.

NSMenu *menu = [[NSMenu alloc] initWithTitle:@"Youlà"];

[menu addItem:[[NSMenuItem alloc] initWithTitle:@"You" action:@selector(john:) keyEquivalent:@""]];
[menu release];

with GNUstep, the same code doesn't dealloc the menu because in NSMenu _notifications retain the menu itself (in my experience). That's not nice, because you must remove each menu item retained in the menu to be able to dealloc it.

Other example :
NSMenu *menu = [[NSMenu alloc] initWithTitle:@"Youlà"];
NSMenu *item = [[NSMenuItem alloc] initWithTitle:@"You" action:@selector(john:) keyEquivalent:@""];

[menu addItem:item];
[menu release];
menu = [[NSMenu alloc] initWithTitle:@"other"];
[menu addItem:item];

The code above which is ok with Cocoa doesn't work with GNUstep.

Last words. You decide... You are involved for far more time than me in GNUstep :-). In my opinion, my fix could be not very well written but that doesn't go against the fact there is a problem.

I will take some time to look at it again. To be sure, I'm not saying something wrong.


Quentin Mathé

reply via email to

[Prev in Thread] Current Thread [Next in Thread]