]> git.lyx.org Git - lyx.git/blobdiff - src/BufferList.cpp
Update it.po
[lyx.git] / src / BufferList.cpp
index 0b76f13b87308dd8dde5435e7bed9b9e7d28d133..5e83c7b63ebe967dcad3d87f933a005ab07f9313 100644 (file)
@@ -96,10 +96,15 @@ void BufferList::release(Buffer * buf)
        BufferStorage::iterator const it =
                find(bstore.begin(), bstore.end(), buf);
        if (it != bstore.end()) {
+               Buffer const * parent = buf->parent();
                Buffer * tmp = (*it);
                bstore.erase(it);
                LASSERT(tmp, return);
                delete tmp;
+               if (parent)
+                       // If this was a child, update the parent's buffer
+                       // to avoid crashes due to dangling pointers (bug 9979)
+                       parent->updateBuffer();
        }
 }
 
@@ -196,7 +201,7 @@ Buffer * BufferList::next(Buffer const * buf) const
 
        if (bstore.empty())
                return 0;
-       BufferStorage::const_iterator it = 
+       BufferStorage::const_iterator it =
                        find(bstore.begin(), bstore.end(), buf);
        LASSERT(it != bstore.end(), return 0);
        ++it;
@@ -212,7 +217,7 @@ Buffer * BufferList::previous(Buffer const * buf) const
 
        if (bstore.empty())
                return 0;
-       BufferStorage::const_iterator it = 
+       BufferStorage::const_iterator it =
                        find(bstore.begin(), bstore.end(), buf);
        LASSERT(it != bstore.end(), return 0);
 
@@ -249,13 +254,22 @@ void BufferList::emergencyWriteAll()
 }
 
 
+void BufferList::invalidateConverterCache() const
+{
+       BufferStorage::const_iterator it = bstore.begin();
+       BufferStorage::const_iterator const en = bstore.end();
+       for (; it != en; ++it)
+               (*it)->params().invalidateConverterCache();
+}
+
+
 bool BufferList::exists(FileName const & fname) const
 {
        return getBuffer(fname) != 0;
 }
 
 
- bool BufferList::isLoaded(Buffer const * b) const
+bool BufferList::isLoaded(Buffer const * b) const
 {
        if (!b)
                return false;
@@ -265,12 +279,22 @@ bool BufferList::exists(FileName const & fname) const
 }
 
 
+bool BufferList::isInternal(Buffer const * b) const
+{
+       if (!b)
+               return false;
+       BufferStorage::const_iterator cit =
+               find(binternal.begin(), binternal.end(), b);
+       return cit != binternal.end();
+}
+
+
 bool BufferList::isOthersChild(Buffer * parent, Buffer * child)
 {
        LASSERT(parent, return false);
        LASSERT(child, return false);
        LASSERT(parent->isChild(child), return false);
-       
+
        // Does child document have a different parent?
        Buffer const * parent_ = child->parent();
        if (parent_ && parent_ != parent)