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
This commit is contained in:
Vincent van Ravesteijn 2009-10-29 23:28:08 +00:00
parent fb2b817346
commit d156d11738
3 changed files with 11 additions and 9 deletions

View File

@ -2337,7 +2337,7 @@ DocIterator Buffer::firstChildPosition(Buffer const * child)
}
std::vector<Buffer *> Buffer::getChildren() const
std::vector<Buffer *> Buffer::getChildren(bool grand_children) const
{
std::vector<Buffer *> clist;
// loop over children
@ -2346,12 +2346,14 @@ std::vector<Buffer *> Buffer::getChildren() const
for (; it != end; ++it) {
Buffer * child = const_cast<Buffer *>(it->first);
clist.push_back(child);
if (grand_children) {
// there might be grandchildren
std::vector<Buffer *> glist = child->getChildren();
for (vector<Buffer *>::const_iterator git = glist.begin();
git != glist.end(); ++git)
clist.push_back(*git);
}
}
return clist;
}

View File

@ -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<Buffer *> getChildren() const;
/// return a vector with all children (and grandchildren)
std::vector<Buffer *> getChildren(bool grand_children = true) const;
/// Is buffer read-only?
bool isReadonly() const;

View File

@ -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<Buffer *> clist = buf.getChildren();
vector<Buffer *> clist = buf.getChildren(false);
for (vector<Buffer *>::const_iterator it = clist.begin();
it != clist.end(); ++it) {
// If a child is dirty, do not close