diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index d44065f07c..36739dbc79 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -584,34 +584,6 @@ void GuiView::closeEvent(QCloseEvent * close_event) } -bool GuiView::closeBufferAll(bool in_close_event) -{ - GuiWorkArea * active_wa = currentMainWorkArea(); - setCurrentWorkArea(active_wa); - - // We might be in a situation that there is still a tabWorkArea, but - // there are no tabs anymore. This can happen when we get here after a - // TabWorkArea::lastWorkAreaRemoved() signal. Therefore we count how - // many TabWorkArea's have no documents anymore. - int empty_twa = 0; - - // We have to call count() each time, because it can happen that - // more than one splitter will disappear in one iteration (bug 5998). - for (; d.splitter_->count() > empty_twa; ) { - TabWorkArea * twa = d.tabWorkArea(empty_twa); - - if (twa->count() == 0) - ++empty_twa; - else { - setCurrentWorkArea(twa->currentWorkArea()); - if (!closeTabWorkArea(twa, true, active_wa)) - return false; - } - } - return true; -} - - void GuiView::dragEnterEvent(QDragEnterEvent * event) { if (event->mimeData()->hasUrls()) @@ -1903,6 +1875,48 @@ bool GuiView::closeBuffer() } +bool GuiView::closeBufferAll(bool in_close_event) +{ + // First close all workareas. This will make + // sure that dirty buffers are saved. + if (!closeWorkAreaAll(in_close_event)) + return false; + + // Now close the hidden buffers. We prevent hidden + // buffers from being dirty, so we can just close them. + theBufferList().closeAll(); + return true; +} + + +bool GuiView::closeWorkAreaAll(bool in_close_event) +{ + GuiWorkArea * active_wa = currentMainWorkArea(); + setCurrentWorkArea(active_wa); + + // We might be in a situation that there is still a tabWorkArea, but + // there are no tabs anymore. This can happen when we get here after a + // TabWorkArea::lastWorkAreaRemoved() signal. Therefore we count how + // many TabWorkArea's have no documents anymore. + int empty_twa = 0; + + // We have to call count() each time, because it can happen that + // more than one splitter will disappear in one iteration (bug 5998). + for (; d.splitter_->count() > empty_twa; ) { + TabWorkArea * twa = d.tabWorkArea(empty_twa); + + if (twa->count() == 0) + ++empty_twa; + else { + setCurrentWorkArea(twa->currentWorkArea()); + if (!closeTabWorkArea(twa, true, active_wa)) + return false; + } + } + return true; +} + + bool GuiView::closeWorkArea(GuiWorkArea * wa, bool close_buffer, bool in_close_event, bool mark_active) { diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index 140d494b7f..e2a1d49bb6 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -309,6 +309,8 @@ private: bool saveBufferIfNeeded(Buffer & buf, bool hiding); /// bool closeBufferAll(bool in_close_event = false); + /// + bool closeWorkAreaAll(bool in_close_event = false); /// is the buffer in this workarea also shown in another tab ? /// This tab can either be in the same view or in another one. bool inMultiTabs(GuiWorkArea * wa);