X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferList.cpp;h=538df77a1de2005553f3df4dda4ddbdaae8130ed;hb=4300feb8595c8542050adedf664cd4bfda7ede12;hp=b068f66e5e1ba4e66e92fa97faa7d47ad63199a5;hpb=0b67e103e97a0c12fd18382152d762fc8d95dff1;p=lyx.git diff --git a/src/BufferList.cpp b/src/BufferList.cpp index b068f66e5e..538df77a1d 100644 --- a/src/BufferList.cpp +++ b/src/BufferList.cpp @@ -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); @@ -236,7 +241,6 @@ void BufferList::updateIncludedTeXfiles(string const & masterTmpDir, (*it)->markDepClean(masterTmpDir); } } - runparams.is_child = false; } @@ -264,7 +268,7 @@ bool BufferList::exists(FileName const & fname) const } - bool BufferList::isLoaded(Buffer const * b) const +bool BufferList::isLoaded(Buffer const * b) const { if (!b) return false; @@ -274,12 +278,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)