From 0e5f082a570129f5e31dab7e8c8347a266f4500d Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Tue, 18 Aug 2009 19:04:39 +0000 Subject: [PATCH] Dissect closeBufferAll and closeTabWorkArea. Unfortunately, I have two pass ugly parameters. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31122 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiView.cpp | 44 ++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 5720b6af2e..f80ba0d449 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -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()) -- 2.39.5