I’m creating a menu bar for my app in my main window class, using the same calls as are found in the juce demo:
myCommandManager = new ApplicationCommandManager(); myCommandManager->registerAllCommandsForTarget(this); myCommandManager->registerAllCommandsForTarget(JUCEApplication::getInstance()); addKeyListener(myCommandManager->getKeyMappings); setMenuBar(this, 20); setApplicationCommandManagerToWatch(myCommandManager);
All this works without a problem, but on quit, I throw an exception in MenuBarModel::removeListener(), because my MenuBarComponent is not in the list of listeners for my MenuBarModel.
The call to setMenuBar() creates the MenuBarComponent, and is passed my window as it’s MenuBarModel, so I would think that the DocumentWindow class would be responsible for deleting things in the right order. What has gone astray here?
In the juce example, the only difference is that the content component is the MenuBarModel and ApplicationCommandTarget. Is it wrong to add that functionality to my main window instead?