Re: Sometimes all my menus are disabled
Re: Sometimes all my menus are disabled
- Subject: Re: Sometimes all my menus are disabled
- From: Andreas Falkenhahn <email@hidden>
- Date: Mon, 13 Feb 2017 15:12:59 +0100
On 12.02.2017 at 21:49 Kyle Sluder wrote:
> There are plenty of ways to write refcounting bugs. But the
> refcounting bug is just a theory. All we know for sure is that
> something is disabling the menu items. I assume you have not turned
> off the default autoenablesItems property on the menu, so that leaves a few possibilities:
> 1. The target of your menu items is being replaced with an object
> that does not respond to -menuClick:.
> 2. The target of your menu items is being deallocated, and a new
> object is being allocated in its place that does not respond to -menuClick:.
> 3. The target of your menu items is being deallocated, and
> NSMenuItem’s weak target pointer is being nilled out (special case of #1).
> 4. The menu has a delegate, and it implements of one of the menu
> update callbacks to disable the menu items.
> 5. Some arbitrary object in your app is grabbing a reference to the menu items and disabling them.
Thanks for the feedback. Unfortunately, I'm pretty much out of ideas now.
I started cutting down my program to the absolute minimum to see if the
error would go away. Well, it didn't. This is the code that's left of my
program now:
#import "AppDelegate.h"
@implementation AppDelegate
- (void) clickButton:(id)sender {}
- (void) menuClick:(id)sender {}
- (void) applicationDidFinishLaunching:(NSNotification *) aNotification
{
[mainWindow makeKeyAndOrderFront:nil];
}
@end
----
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
return NSApplicationMain(argc, argv);
}
And the error is still there. Bottom line: The error must be in the
MainMenu.nib or in the Xcode project. Maybe Xcode has messed up one of
the files when migrating it from the old Xcode on PowerPC to Xcode 8.
Unfortunately, I don't know where to look because I remember nothing about
Interface Builder. That's why I have uploaded a VERY SMALL test project
here: http://www.falkenhahn.com/tmp/guitest.tar.gz
It really only contains the code quoted above, a single window with a
single button and the original menu bar that is behaving erratically.
As I said in my first mail, the really confusing fact is that it usually
works just fine. But in every 3rd attempt or so suddenly all menus are
disabled and I have no idea what's going on! It is really weird but it
is clearly reproducible. I know I said before that it fails in 1 out of 10
attempts but it's more like 1 in 3 attempts. It's really clearly reproducible.
It happens all the time though not always.
As I'm really out of ideas now I'd be extremely glad if somebody with
IB experience could just take a quick look at this project and maybe come up
with an explanation. As I said, it's an absolutely minimal project.
It should be really straightforward to analyze for people who are experienced
with IB.
Thanks a lot for any help!
--
Best regards,
Andreas Falkenhahn mailto:email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden