From 7df55755ac791c3e1ce3dd0e7ec9acc73a9ab634 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sun, 3 Dec 2006 13:09:57 +0000 Subject: [PATCH] Fix memory leaks with multiple windows and crash when deleteOnClose is set. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16157 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiView.C | 5 ++--- src/frontends/qt4/QLPopupMenu.C | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/frontends/qt4/GuiView.C b/src/frontends/qt4/GuiView.C index 2615e34462..c42f97090b 100644 --- a/src/frontends/qt4/GuiView.C +++ b/src/frontends/qt4/GuiView.C @@ -157,9 +157,7 @@ GuiView::GuiView(int id) { // Qt bug? signal lastWindowClosed does not work setAttribute(Qt::WA_QuitOnClose, false); - // FIXME: the following statement avoids memory leaks but produces a - // crash after a new window has been closed (click into the menu) - //setAttribute(Qt::WA_DeleteOnClose, true); + setAttribute(Qt::WA_DeleteOnClose, true); // hardcode here the platform specific icon size d.smallIconSize = 14; // scaling problems @@ -180,6 +178,7 @@ GuiView::GuiView(int id) GuiView::~GuiView() { + menubar_.reset(); delete &d; } diff --git a/src/frontends/qt4/QLPopupMenu.C b/src/frontends/qt4/QLPopupMenu.C index 52b94d3dd2..03c221ff50 100644 --- a/src/frontends/qt4/QLPopupMenu.C +++ b/src/frontends/qt4/QLPopupMenu.C @@ -72,6 +72,9 @@ void QLPopupMenu::update() if (name_.empty()) return; + // Here, We make sure that theLyXFunc points to the correct LyXView. + theLyXFunc().setLyXView(owner_->view()); + Menu const & fromLyxMenu = owner_->backend().getMenu(name_); owner_->backend().expand(fromLyxMenu, topLevelMenu_, owner_->view()->buffer());