]> git.lyx.org Git - lyx.git/blobdiff - src/BufferList.cpp
Hebrew translation updates by Ran
[lyx.git] / src / BufferList.cpp
index 29e24c83cc9871fefc4b08e8be9101d0f2466d89..4512cae4abdd8e5fc521f3089f217b90425f8f12 100644 (file)
@@ -29,7 +29,7 @@
 #include "support/lstrings.h"
 #include "support/Package.h"
 
-#include "support/assert.h"
+#include "support/lassert.h"
 #include <boost/bind.hpp>
 
 #include <algorithm>
@@ -335,4 +335,28 @@ int BufferList::bufferNum(string const & name) const
 }
 
 
+bool BufferList::releaseChild(Buffer * parent, Buffer * child)
+{
+       LASSERT(parent, return false);
+       LASSERT(child, return false);
+       LASSERT(parent->isChild(child), return false);
+
+       // Child document has a different parent, don't close it.
+       if (child->parent() != parent)
+               return false;
+
+       BufferStorage::iterator it = bstore.begin();
+       BufferStorage::iterator end = bstore.end();
+       for (; it != end; ++it) {
+               Buffer * buf = *it;
+               if (buf != parent && buf->isChild(child)) {
+                       child->setParent(0);
+                       return false;
+               }
+       }
+       release(child);
+       return true;
+}
+
+
 } // namespace lyx