// Gives some error box here.
return;
-#ifdef Q_WS_MACX
- d->global_menubar_->clear();
- delete d->global_menubar_;
- // Create the global default menubar which is shown for the dialogs
- // and if no GuiView is visible.
- d->global_menubar_ = new GlobalMenuBar();
-
- // init the global menubar on Mac. This must be done after the session
- // was recovered to know the "last files".
- d->menus_.fillMenuBar(d->global_menubar_, 0, true);
-#endif
+ if (d->global_menubar_)
+ d->menus_.fillMenuBar(d->global_menubar_, 0, false);
QHash<int, GuiView *>::iterator it;
for (it = d->views_.begin(); it != d->views_.end(); ++it) {
/// Mac special menu.
/** This defines a menu whose entries list the FuncRequests
that will be removed by expand() in other menus. This is
- used by the Qt/Mac code
+ used by the Qt/Mac code.
+
+ NOTE: Qt does not remove the menu items when clearing a QMenuBar,
+ such that the items will keep accessing the FuncRequests in
+ the MenuDefinition. While Menus::Impl might be recreated,
+ we keep mac_special_menu_ in memory by making it static.
*/
- MenuDefinition specialmenu_;
+ static MenuDefinition mac_special_menu_;
///
MenuList menulist_;
NameMap name_map_;
};
+
+MenuDefinition Menus::Impl::mac_special_menu_;
+
+
/*
Here is what the Qt documentation says about how a menubar is chosen:
const size_t num_entries = sizeof(entries) / sizeof(entries[0]);
// the special menu for Menus. Fill it up only once.
- if (specialmenu_.size() == 0) {
+ if (mac_special_menu_.size() == 0) {
for (size_t i = 0 ; i < num_entries ; ++i) {
FuncRequest const func(entries[i].action,
from_utf8(entries[i].arg));
- specialmenu_.add(MenuItem(MenuItem::Command,
+ mac_special_menu_.add(MenuItem(MenuItem::Command,
entries[i].label, func));
}
}
// add the entries to a QMenu that will eventually be empty
// and therefore invisible.
QMenu * qMenu = qmb->addMenu("special");
- MenuDefinition::const_iterator cit = specialmenu_.begin();
- MenuDefinition::const_iterator end = specialmenu_.end();
+ MenuDefinition::const_iterator cit = mac_special_menu_.begin();
+ MenuDefinition::const_iterator end = mac_special_menu_.end();
for (size_t i = 0 ; cit != end ; ++cit, ++i) {
Action * action = new Action(view, QIcon(), cit->label(),
cit->func(), QString(), qMenu);
break;
case MenuItem::Command:
- if (!specialmenu_.hasFunc(cit->func()))
+ if (!mac_special_menu_.hasFunc(cit->func()))
tomenu.addWithStatusCheck(*cit);
}
}
{
if (initial) {
#ifdef Q_WS_MACX
- // setup special mac specific menu item
+ // setup special mac specific menu items, but only do this
+ // the first time a QMenuBar is created. Otherwise Qt will
+ // create duplicate items in the application menu. It seems
+ // that Qt does not remove them when the QMenubar is cleared.
+ LYXERR(Debug::GUI, "Creating Mac OS X special menu bar");
d->macxMenuBarInit(view, qmb);
#endif
} else {