Subject: bug#45502: [PATCH] Prettier key bindings in NS menu entries

From: Alan Third <[email-masked]>
Date: Tue, 29 Dec 2020 23:49:02 +0000

On Tue, Dec 29, 2020 at 11:53:59PM +0100, Mattias Engdegård wrote:
> 29 dec. 2020 kl. 22.24 skrev Alan Third <[email-masked]>:
> 
> > I've pushed a small change. I also set the alloc'd objects to
> > autorelease. We need to do that because when they're assigned to the
> > NSMenuItem it will retain them, and because we alloc'd them we already
> > have them retained once.
> > 
> > At least I hope that's right. For some reason I've found the
> > retain/release cycle really hard to understand, but I think I'm
> > getting there now.
> 
> Thanks! Is this the standard way of doing it? The objects that you
> marked autorelease (tab and pstyle) are only used for the extent of
> that method; I take it you prefer autorelease to sending them
> 'release' at the end of the method?

I think it's maybe visually a little neater to use autorelease, but
either way works and I would probably do it the other way in different
circumstances. Feel free to change it if you want.

> Presumably 'atitle' should be sent autorelease (or release) as well?

Yes, I missed that one. And actually, I think the alloc'd NSMenuItem
on line 484 will need released too. It should probably be autoreleased
because it's returned to the calling function, and the caller can then
decide whether to retain it or not (it doesn't in this case).

-- 
Alan Third