From: Vincent van Ravesteijn Date: Thu, 29 Oct 2009 23:28:08 +0000 (+0000) Subject: Fix part of bug #6251: When closing a buffer, only close the direct children. All... X-Git-Tag: 2.0.0~5261 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=d156d117388a4aacbaa57d81dd9d12e21572bda4;p=features.git Fix part of bug #6251: When closing a buffer, only close the direct children. All grandchildren will be closed recursively by the children _and_ before it will be close by the grandparent. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31797 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Buffer.cpp b/src/Buffer.cpp index b42f14d028..34316c1a14 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -2337,7 +2337,7 @@ DocIterator Buffer::firstChildPosition(Buffer const * child) } -std::vector Buffer::getChildren() const +std::vector Buffer::getChildren(bool grand_children) const { std::vector clist; // loop over children @@ -2346,11 +2346,13 @@ std::vector Buffer::getChildren() const for (; it != end; ++it) { Buffer * child = const_cast(it->first); clist.push_back(child); - // there might be grandchildren - std::vector glist = child->getChildren(); - for (vector::const_iterator git = glist.begin(); - git != glist.end(); ++git) - clist.push_back(*git); + if (grand_children) { + // there might be grandchildren + std::vector glist = child->getChildren(); + for (vector::const_iterator git = glist.begin(); + git != glist.end(); ++git) + clist.push_back(*git); + } } return clist; } diff --git a/src/Buffer.h b/src/Buffer.h index af69950eb1..be7caa6519 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -311,8 +311,8 @@ public: /// \return true if \p child is a child of this \c Buffer. bool isChild(Buffer * child) const; - /// return a vector with all children and grandchildren - std::vector getChildren() const; + /// return a vector with all children (and grandchildren) + std::vector getChildren(bool grand_children = true) const; /// Is buffer read-only? bool isReadonly() const; diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index d352f880c9..bfbe8d2605 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -2065,7 +2065,7 @@ bool GuiView::closeBuffer(Buffer & buf) // 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 (!closing_) { - vector clist = buf.getChildren(); + vector clist = buf.getChildren(false); for (vector::const_iterator it = clist.begin(); it != clist.end(); ++it) { // If a child is dirty, do not close