From fb2b8173467518d4364b336ef1a28ef01582a4d4 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Thu, 29 Oct 2009 23:22:50 +0000 Subject: [PATCH] Dissect closeWorkArea and closeBuffer. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31796 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiView.cpp | 33 ++++++++++++++++++++------------- src/frontends/qt4/GuiView.h | 2 ++ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 4dc56a5039..d352f880c9 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -2041,13 +2041,30 @@ bool GuiView::closeWorkAreaAll() bool GuiView::closeWorkArea(GuiWorkArea * wa, bool close_buffer) { + if (!wa) + return false; + Buffer & buf = wa->bufferView().buffer(); + if (close_buffer) + return closeBuffer(buf); + else { + if (!inMultiTabs(wa)) + if (!saveBufferIfNeeded(buf, true)) + return false; + removeWorkArea(wa); + return true; + } +} + + +bool GuiView::closeBuffer(Buffer & buf) +{ // If we are in a close_event all children will be closed in some time, // so no need to do it here. This will ensure that the children end up // in the session file in the correct order. If we close the master // buffer, we can close or release the child buffers here too. - if (close_buffer && !closing_) { + if (!closing_) { vector clist = buf.getChildren(); for (vector::const_iterator it = clist.begin(); it != clist.end(); ++it) { @@ -2069,18 +2086,8 @@ bool GuiView::closeWorkArea(GuiWorkArea * wa, bool close_buffer) for (size_t i = 0; i < theSession().bookmarks().size(); ++i) theLyXFunc().gotoBookmark(i+1, false, false); - // if we are only hiding the buffer and there are multiple views - // of the buffer, then we do not need to ensure a clean buffer. - bool const allow_dirty = inMultiTabs(wa) && !close_buffer; - - if (allow_dirty || saveBufferIfNeeded(buf, !close_buffer)) { - // save in sessions if requested - // do not save childs if their master - // is opened as well - if (!close_buffer) - removeWorkArea(wa); - else - theBufferList().release(&buf); + if (saveBufferIfNeeded(buf, false)) { + theBufferList().release(&buf); return true; } return false; diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index ae85894e5f..e72b1802fa 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -105,6 +105,8 @@ public: bool hideWorkArea(GuiWorkArea * wa); /// closes the workarea bool closeWorkArea(GuiWorkArea * wa); + /// closes the buffer + bool closeBuffer(Buffer & buf); /// void openDocument(std::string const & filename); /// -- 2.39.2