Issue with native mac menu


When opening a modal window in the menuItemSelected Callback and the column is of the Menu is “Help”, i get a Obj-C error. No time to investigate yet, will add some info to this topic later.


i could reproduce it with the Juce demo:

Change the second menu bar to “Help”

const StringArray getMenuBarNames() { //const char* const names[] = { "Demo", "Look-and-feel", 0 }; const char* const names[] = { "Demo", "Help", 0 };

add a Menu-Item

else if (menuIndex == 1) { menu.addItem(1111, "Crash", true, false);

open a Modal-Window directly from the Callback (not using the command manager!)

void menuItemSelected (int menuItemID, int /*topLevelMenuIndex*/) { if (menuItemID==1111) { AlertWindow::showMessageBox(AlertWindow::InfoIcon,"Test","Crash","OK"); };


  1. Open the Juce Demo
  2. Click on “Use the native OSX Menu”
  3. Click on Crash
    -> after closing the AlertBox you get a crash


Call Stack:

#0 0x909e3ed7 in objc_msgSend #1 0x01a22fa0 in ?? #2 0x96f817eb in -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] #3 0x96f816da in -[NSMenu performActionForItemAtIndex:] #4 0x96f8168d in -[NSMenu _internalPerformActionForItemAtIndex:] #5 0x96f81537 in -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] #6 0x96f75c61 in NSSLMMenuEventHandler #7 0x9624fc2f in DispatchEventToHandlers #8 0x9624eef6 in SendEventToEventTargetInternal #9 0x962717f3 in SendEventToEventTarget #10 0x9629de87 in SendHICommandEvent #11 0x962c2b90 in SendMenuCommandWithContextAndModifiers #12 0x962c2b47 in SendMenuItemSelectedEvent #13 0x962c2a5d in FinishMenuSelection #14 0x96292160 in MenuSelectCore #15 0x962918bb in _HandleMenuSelection2 #16 0x962916d9 in _HandleMenuSelection #17 0x96f6f1a2 in _NSHandleCarbonMenuEvent #18 0x96f43d3e in _DPSNextEvent #19 0x96f42fce in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] #20 0x96f05247 in -[NSApplication run] #21 0x003e264d in juce::MessageManager::runDispatchLoop at #22 0x00185126 in juce::JUCEApplication::main at juce_Application.cpp:241 #23 0x00185342 in juce::JUCEApplication::main at juce_Application.cpp:275

Maybe it has to do with the blue search bar (which is integrated in the Menu-Bar by OSX)


Jeez… Apple have hard-wired the name “help” to make the menu behave differently (!)

Ok, I guess I’ll have to make it invoke that callback asynchronously.


Hi Jules,

Did you fix this - as I think I’ve just encountered a similar problem in Juce 1.53 …?

Basically, I’ve got a modal dialog open, close it - and the menu system crashes indirectly under _internalPerformActionForItemAtIndex …

NB this only shows-up when using the Guard Page allocator - doesn’t happen for every dialog, can’t quite nail-down the pattern here - though I have a feeling it might be related to menuItemsChanged() and modal dialogs…

EDIT: My work-around for this was, in response to a menu item that invoked a modal dialog and called menuItemsChanged()… use postMessage to handle the dialog invocation in a deferred manner, and use postMessage to handle the result from the dialog invocation in a deferred manner. All now sorted from my perspective :slight_smile:

Best wishes,



Yeah, I seem to remember making it async… Let me know if you find anything I should know about.


:slight_smile: I think just a warning about this in the docs, around showModalDialog, would be a reasonable solution. :slight_smile:

Best wishes,