[Top][All Lists]

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

Re: [PATCH] Fix NSMenu retainCount problem

From: Fred Kiefer
Subject: Re: [PATCH] Fix NSMenu retainCount problem
Date: Thu, 05 Feb 2004 22:37:16 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030821

Quentin Mathé wrote:
Here is the patch, two exactly, I was talking about.

NSMenu.m patch reworks the notifications use in order that the menu itself hasn't be included in a notification until the notification is sent.

I'm less sure for the NSMenuView.m patch : it only removes few lines which seems to have no reason to be there and caused a retain on NSMenu. Must be confirmed.

NSMenu patch has fixed the code below :

NSMenu *menu = [[NSMenu alloc] initWithTitle:@"boum"];
[menu addItem:menuItem];
// now the menu retain count is still 1 and not higher

NSMenuView patch has fixed the code below :

NSMenu *menu = [[NSMenu alloc] initWithTitle:@"boum"];
[NSMenu popUpContextMenu:menu event:event view:view];
[menu release];
// now the menu is released and deallocated

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.

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.

reply via email to

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