From d1511fcb47f8fca8193c8ea426a50de0527af7a4 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Tue, 26 Feb 2008 14:15:32 +0000 Subject: [PATCH] * GuiView::closeEvent(): adjust buffer closing WRT multi-view and child documents. - a child document is kept loaded in any case. It is saved if needed before being hidden. - a document which is not viewed in another window is closed now. - we do nothing for documents that are also viewed in another window. There is two FIXME related to this last item in the code: // FIXME 1: should we put an alert box here that the buffer // is viewed elsewhere? // FIXME 2: should we try to save this buffer in any case? //saveBuffer(b); git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23250 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiView.cpp | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index c2bcf1b8e9..de370d0c69 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -390,6 +390,42 @@ void GuiView::closeEvent(QCloseEvent * close_event) } } + while (Buffer * b = buffer()) { + if (b->parent()) { + // This is a child document, just close the tab after saving + // but keep the file loaded. + if (!saveBuffer(*b)) { + close_event->ignore(); + return; + } + removeWorkArea(d.current_work_area_); + continue; + } + + std::vector const & ids = guiApp->viewIds(); + for (int i = 0; i != ids.size(); ++i) { + if (id_ == ids[i]) + continue; + if (GuiWorkArea * wa = guiApp->view(ids[i]).workArea(*b)) { + // FIXME 1: should we put an alert box here that the buffer + // is viewed elsewhere? + // FIXME 2: should we try to save this buffer in any case? + //saveBuffer(b); + + // This buffer is also opened in another view, so + // but close the associated work area nevertheless. + removeWorkArea(d.current_work_area_); + // but don't close it. + b = 0; + break; + } + } + if (b && !closeBuffer(*b)) { + close_event->ignore(); + return; + } + } + // Make sure that no LFUN use this close to be closed View. theLyXFunc().setLyXView(0);