]> git.lyx.org Git - lyx.git/commitdiff
Dissect closeBufferAll and closeTabWorkArea. Unfortunately, I have two pass ugly...
authorVincent van Ravesteijn <vfr@lyx.org>
Tue, 18 Aug 2009 19:04:39 +0000 (19:04 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Tue, 18 Aug 2009 19:04:39 +0000 (19:04 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31122 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiView.cpp

index 5720b6af2e052ab605636611bfa9dc8278f94e61..f80ba0d449e45523d04b5540c4202dfd4158ec13 100644 (file)
@@ -600,24 +600,11 @@ bool GuiView::closeBufferAll(bool in_close_event)
        for (; d.splitter_->count() > empty_twa; ) {
                TabWorkArea * twa = d.tabWorkArea(empty_twa);
                                
-               int twa_count = twa->count();
                if (twa->count() == 0)
                        ++empty_twa;
-
-               for (; twa == d.tabWorkArea(empty_twa) && twa_count; --twa_count) {
-                       twa->setCurrentIndex(twa_count-1);
-
-                       GuiWorkArea * wa = twa->currentWorkArea();
-                       bool const is_active_wa = active_wa == wa;
-                       Buffer & b = wa->bufferView().buffer();
-
-                       // We only want to close the buffer if the same buffer is not in
-                       // another view.
-                       bool const close_buffer = !(inMultiViews(wa) || b.parent());
-
-                       // closeBuffer() needs buffer workArea still alive and
-                       // set as currrent one, and destroys it
-                       if (!closeWorkArea(wa, close_buffer, in_close_event, is_active_wa))
+               else {
+                       setCurrentWorkArea(twa->currentWorkArea());
+                       if (!closeTabWorkArea(twa, true, active_wa))
                                return false;
                }
        }
@@ -1960,6 +1947,31 @@ bool GuiView::closeWorkArea(GuiWorkArea * wa, bool close_buffer,
 }
 
 
+bool GuiView::closeTabWorkArea(TabWorkArea * twa, bool in_close_event,
+                                                          GuiWorkArea * main_work_area)
+{
+       while (twa == d.currentTabWorkArea()) {
+               twa->setCurrentIndex(twa->count()-1);
+
+               GuiWorkArea * wa = twa->currentWorkArea();
+               bool const is_active_wa = main_work_area == wa;
+               Buffer & b = wa->bufferView().buffer();
+
+               // We only want to close the buffer if the same buffer is not visible
+               // in another view, and if this is not a child and if we are closing
+               // a view (not a tabgroup).
+               bool const close_buffer = 
+                       !inMultiViews(wa) && !b.parent() && in_close_event;
+
+               // closeBuffer() needs buffer workArea still alive and
+               // set as currrent one, and destroys it
+               if (!closeWorkArea(wa, close_buffer, true, is_active_wa))
+                       return false;
+       }
+       return true;
+}
+
+
 bool GuiView::saveBufferIfNeeded(Buffer & buf, bool hiding)
 {
        if (buf.isClean() || buf.paragraphs().empty())