From a37a73e3c949003766a7481ca72c7971c059fe3d Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 21 Nov 2007 21:14:34 +0000 Subject: [PATCH] Introducing GuiMenubar::init() to avoid destructing the object in order to re-initialize it. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21694 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiMenubar.cpp | 9 +++++++++ src/frontends/qt4/GuiMenubar.h | 3 +++ src/frontends/qt4/GuiView.cpp | 3 +-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/frontends/qt4/GuiMenubar.cpp b/src/frontends/qt4/GuiMenubar.cpp index 194095ddff..a06be19ae9 100644 --- a/src/frontends/qt4/GuiMenubar.cpp +++ b/src/frontends/qt4/GuiMenubar.cpp @@ -39,6 +39,12 @@ namespace frontend { GuiMenubar::GuiMenubar(LyXView * view, MenuBackend & mbe) : owner_(static_cast(view)), menubackend_(mbe) +{ + init(); +} + + +void GuiMenubar::init() { macxMenuBarInit(); @@ -55,6 +61,9 @@ GuiMenubar::GuiMenubar(LyXView * view, MenuBackend & mbe) << menubackend_.getMenubar().size()); } + // Clear all menubar contents before filling it. + owner_->menuBar()->clear(); + Menu menu; menubackend_.expand(menubackend_.getMenubar(), menu, owner_->buffer()); diff --git a/src/frontends/qt4/GuiMenubar.h b/src/frontends/qt4/GuiMenubar.h index e52906c356..fd48ea3ccf 100644 --- a/src/frontends/qt4/GuiMenubar.h +++ b/src/frontends/qt4/GuiMenubar.h @@ -36,6 +36,9 @@ public: ~GuiMenubar(); + /// + void init(); + /// opens a top-level submenu given its name void openByName(QString const & name); diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 027a7fe68d..66ed4feccf 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -1217,9 +1217,8 @@ void GuiView::resetDialogs() { // Make sure that no LFUN uses any LyXView. theLyXFunc().setLyXView(0); - delete d.menubar_; d.toolbars_->init(); - d.menubar_ = new GuiMenubar(this, menubackend); + d.menubar_->init(); if (d.layout_) d.layout_->updateContents(true); }