|
From: | Doug Simons |
Subject: | Re: What happened to the code freeze? |
Date: | Fri, 23 Apr 2010 11:59:28 -0600 |
On Apr 23, 2010, at 2:21 AM, Fred Kiefer wrote:
It turns out that the call to setSupermenu: that I added (in the insert method) does absolutely nothing. It was the change I made to setSupermenu:self instead of setSupermenu:nil during decoding that fixed the problem for me. But I didn't look closely enough at the time to fully understand why that fixed it. As you've astutely observed, that looks like it ought to cause problems. But what's actually happening is that everything is already set at that point. I should have paid more attention to the FIXME comment at that point in the code: // FIXME: We propably don't need this, as all the fields are // already set up for the submenu item. if (sub != nil) { [sub setSupermenu: nil]; [self setSubmenu: sub forItem: item]; } By changing it to call [sub setSupermenu:self] what I achieved was a no-op, since the supermenu was already set by the earlier call to [self addItem:item]. The next line was also a no-op, since item's submenu was also set already at this point. The root of the problem was the call to [sub setSupermenu: nil] which wiped out the supermenu that was already set correctly! So the correct fix is simply to delete that block of code (and the declaration and assignment of 'sub' a few lines earlier). I've done that, and also delete the other call to setSupermenu: that I had added. Doug |
NSMenu.m
Description: Binary data
[Prev in Thread] | Current Thread | [Next in Thread] |