From 1520629d7cefe09cbc9612806c8abbbd6b36048e Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Sat, 15 Aug 2009 21:46:39 +0000 Subject: [PATCH] If we are hiding a buffer _and_ the buffer is visible in another view/tabgroup, then we don't need to ensure that the buffer is clean. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31065 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiView.cpp | 19 ++++++++++++++++++- src/frontends/qt4/GuiView.h | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index e9e167af33..564d6e52b9 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -1939,8 +1939,12 @@ 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; + Buffer & buf = wa->bufferView().buffer(); - if (saveBufferIfNeeded(buf, !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 @@ -2014,6 +2018,19 @@ bool GuiView::saveBufferIfNeeded(Buffer & buf, bool hiding) } +bool GuiView::inMultiTabs(GuiWorkArea * wa) +{ + Buffer & buf = wa->bufferView().buffer(); + + for (int i = 0; i != d.splitter_->count(); ++i) { + GuiWorkArea * wa_ = d.tabWorkArea(i)->workArea(buf); + if (wa_ && wa_ != wa) + return true; + } + return inMultiViews(wa); +} + + bool GuiView::inMultiViews(GuiWorkArea * wa) { QList const ids = guiApp->viewIds(); diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index 979cbef069..4cf5d027e9 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -304,6 +304,9 @@ private: bool saveBufferIfNeeded(Buffer & buf, bool hiding); /// bool closeBufferAll(bool tolastopened = 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); /// is the buffer in this workarea also shown in another view ? bool inMultiViews(GuiWorkArea * wa); /// -- 2.39.2