]> git.lyx.org Git - features.git/commitdiff
Dissect closeWorkArea and closeBuffer.
authorVincent van Ravesteijn <vfr@lyx.org>
Thu, 29 Oct 2009 23:22:50 +0000 (23:22 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Thu, 29 Oct 2009 23:22:50 +0000 (23:22 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31796 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiView.h

index 4dc56a5039857bf6b8c180f150afeeddc86b78af..d352f880c97c657b3d6a958ebdc571cea866f70c 100644 (file)
@@ -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<Buffer *> clist = buf.getChildren();
                for (vector<Buffer *>::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;
index ae85894e5f0b416fea138e062809703080e4afa6..e72b1802fadba7e552874bada17daf12886343b9 100644 (file)
@@ -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);
        ///