Over-released NSMenuItem on using "Open Recent" via Help menu search
Over-released NSMenuItem on using "Open Recent" via Help menu search
- Subject: Over-released NSMenuItem on using "Open Recent" via Help menu search
- From: Keith Blount <email@hidden>
- Date: Sat, 6 Nov 2010 11:37:18 -0700 (PDT)
Hello,
One of my users has just brought a crasher to my attention regarding the File >
Open Recent menu in my application, and having spent all day banging my head
against a wall, I'm hoping someone on the list might either have seen something
like this before or just see something obvious I'm missing - although it's a
really strange one.
My application is an NSDocument-based app, and my user pointed out that he could
make my application crash every time by following this sequence:
1) Hit shift-cmd-/ to bring up the Help menu with the search field focussed.
2) Type "recent" in the Help menu search field so that the contents of the "Open
Recent" menu would be listed in the Help menu.
3) Pick one of the "Open Recent > ..." menu items now listed in the Help menu.
At this point, the selected document opens, appears on screen for a second, and
then the app crashes.
I can reproduce this every time myself (I've copied the backtrace at the end of
this e-mail). And yet if you go to the File > Open Recent menu and open a
document directly from there, everything is fine - it's only when using the Help
search field and resulting dynamic menu that the crash occurs.
It was an EXC_BAD_ACCESS crash with this error:
FREED(id): message _bindingAdaptor sent to freed object=0x17e36d10
So I turned on NSDebugEnabled, NSZombieEnabled and MallocStackLogging to find
out what was getting over-released or accessed after being released. The result
was:
*** -[NSMenuItem _bindingAdaptor]: message sent to deallocated instance
0x15c28bb0
I then did some nasty -poseAsClass stuff just so that I could NSLog which menu
item was getting called after being released, and sure enough it was one of the
menu items from the "Open Recent" menu (i.e. it had the title of one of the
documents that appear there). I then made a copy of my project and started
stripping out code from my NSDocumentController subclass, NSApplication
subclass, NSApplicationDelegate class, and anything I could think of that could
possibly have a bearing on this - but no joy, it still crashes.
The really strange thing is that my program has no control over that menu and
has nothing to do with it - as I understand it, its population is all handled
internally by NSDocumentController (and my NSDocumentController doesn't touch
it, either - I tried getting rid of all my custom doc controller methods). And
yet no other program I've tried has this problem, and a version of my program
from a year or so ago didn't, so it's obviously something I've introduced
somewhere, somehow. (In case it was some weird Cocoa bug involving using custom
NSDocumentController classes, I set up a test project with a custom document
controller class, and that was fine.)
Given the complexity of this sort of thing, I know it's unlikely anyone is going
to have a magic answer, but if anyone has seen anything like this before, or has
any tips on how I might track this down further, I'd be very grateful for any
ideas - I'm a little nonplussed on what to try next. (The trouble is that it's
going to be difficult to take out an Apple tech support incident on this, too,
as I can't reproduce it in a new Xcode project - unsurprisingly - and I can
hardly send them my rather massive project to sift through. :) )
Many thanks and all the best,
Keith
-- BACKTRACE --
#00x940ed4e7 in ___forwarding___
#10x940ed3b2 in __forwarding_prep_0___
#20x92025e8a in -[NSMenuItem _corePerformAction]
#30x92025ac2 in -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:]
#40x920259ae in -[NSMenu performActionForItemAtIndex:]
#50x92025961 in -[NSMenu _internalPerformActionForItemAtIndex:]
#60x9202580b in -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:]
#70x92019f49 in NSSLMMenuEventHandler
#80x978ecf2f in DispatchEventToHandlers
#90x978ec1f6 in SendEventToEventTargetInternal
#100x9790e9bb in SendEventToEventTarget
#110x9793afa7 in SendHICommandEvent
#120x9795fd1c in SendMenuCommandWithContextAndModifiers
#130x9795fcd1 in SendMenuItemSelectedEvent
#140x9795fbda in FinishMenuSelection
#150x9792f03c in SimulateSelection
#160x9792e8f8 in _HandleMenuSelection2
#170x9792e874 in _HandleMenuSelection
#180x9201348a in _NSHandleCarbonMenuEvent
#190x91fe803a in _DPSNextEvent
#200x91fe72ca in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:]
#210x91fa955b in -[NSApplication run]
#220x91fa15ed in NSApplicationMain
#230x0003276a in main at main.m:13
_______________________________________________
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