]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiMenubar.cpp
Introducing GuiMenubar::init() to avoid destructing the object in order to re-initial...
[lyx.git] / src / frontends / qt4 / GuiMenubar.cpp
index cf523b64eae8752c28eeb7b5045929d21cbdbe86..a06be19ae9be4f7c6049be88fcaebe271e138b38 100644 (file)
@@ -39,22 +39,31 @@ namespace frontend {
 
 GuiMenubar::GuiMenubar(LyXView * view, MenuBackend & mbe)
        : owner_(static_cast<GuiView*>(view)), menubackend_(mbe)
+{
+       init();
+}
+
+
+void GuiMenubar::init()
 {
        macxMenuBarInit();
 
-       LYXERR(Debug::GUI) << "populating menu bar" << to_utf8(menubackend_.getMenubar().name()) << endl;
+       LYXERR(Debug::GUI, "populating menu bar" << to_utf8(menubackend_.getMenubar().name()));
 
        if (menubackend_.getMenubar().size() == 0) {
-               LYXERR(Debug::GUI) << "\tERROR: empty menu bar"
-                       << to_utf8(menubackend_.getMenubar().name()) << endl;
+               LYXERR(Debug::GUI, "\tERROR: empty menu bar"
+                       << to_utf8(menubackend_.getMenubar().name()));
                return;
                //                      continue;
        }
        else {
-               LYXERR(Debug::GUI) << "menu bar entries "
-                       << menubackend_.getMenubar().size();
+               LYXERR(Debug::GUI, "menu bar entries "
+                       << menubackend_.getMenubar().size());
        }
 
+       // Clear all menubar contents before filling it.
+       owner_->menuBar()->clear();
+
        Menu menu;
        menubackend_.expand(menubackend_.getMenubar(), menu, owner_->buffer());
 
@@ -64,18 +73,17 @@ GuiMenubar::GuiMenubar(LyXView * view, MenuBackend & mbe)
        for (; m != end; ++m) {
 
                if (m->kind() != MenuItem::Submenu) {
-                       LYXERR(Debug::GUI) << "\tERROR: not a submenu "
-                               << to_utf8(m->label()) << endl;
+                       LYXERR(Debug::GUI, "\tERROR: not a submenu " << to_utf8(m->label()));
                        continue;
                }
 
-               LYXERR(Debug::GUI) << "menu bar item " << to_utf8(m->label())
-                       << " is a submenu named " << to_utf8(m->submenuname()) << endl;
+               LYXERR(Debug::GUI, "menu bar item " << to_utf8(m->label())
+                       << " is a submenu named " << to_utf8(m->submenuname()));
 
                docstring name = m->submenuname();
                if (!menubackend_.hasMenu(name)) {
-                       LYXERR(Debug::GUI) << "\tERROR: " << to_utf8(name)
-                               << " submenu has no menu!" << endl;
+                       LYXERR(Debug::GUI, "\tERROR: " << to_utf8(name)
+                               << " submenu has no menu!");
                        continue;
                }
 
@@ -150,7 +158,6 @@ void GuiMenubar::macxMenuBarInit()
 #ifdef Q_WS_MACX
        mac_menubar_ = new QMenuBar;
 
-# if QT_VERSION >= 0x040200
        /* Since Qt 4.2, the qt/mac menu code has special code for
           specifying the role of a menu entry. However, it does not
           work very well with our scheme of creating menus on demand,
@@ -211,9 +218,6 @@ void GuiMenubar::macxMenuBarInit()
                qMenu->addAction(action);
 
        }
-# else
-       qt_mac_set_menubar_merge(false);
-# endif // QT_VERSION >= 0x040200
 #endif // Q_WS_MACX
 }