X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferList.cpp;h=ff99a090f35ea08ad398bbb8eabaf1ca92ef9238;hb=f3ee4a0a493fa96be99f5bbc7ee9de00a5f69b34;hp=de5a7ab2ad56fd327d8bbe47aac146b1d2f55c77;hpb=fdbe775b9f5468e8f53dc83a66583f412b5970fb;p=lyx.git diff --git a/src/BufferList.cpp b/src/BufferList.cpp index de5a7ab2ad..ff99a090f3 100644 --- a/src/BufferList.cpp +++ b/src/BufferList.cpp @@ -154,11 +154,9 @@ void BufferList::closeAll() } -FileNameList const & BufferList::fileNames() const +FileNameList BufferList::fileNames() const { - // FIXME THREAD - static FileNameList nvec; - nvec.clear(); + FileNameList nvec; BufferStorage::const_iterator it = bstore.begin(); BufferStorage::const_iterator end = bstore.end(); for (; it != end; ++it) { @@ -269,6 +267,28 @@ bool BufferList::exists(FileName const & fname) const } +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) + return true; + + BufferStorage::iterator it = bstore.begin(); + BufferStorage::iterator end = bstore.end(); + for (; it != end; ++it) { + Buffer * buf = *it; + if (buf != parent && buf->isChild(child)) + return true; + } + return false; +} + + namespace { struct equivalent_to : public binary_function @@ -346,9 +366,18 @@ void BufferList::recordCurrentAuthor(Author const & author) } +void BufferList::updatePreviews() +{ + BufferStorage::iterator it = bstore.begin(); + BufferStorage::iterator end = bstore.end(); + for (; it != end; ++it) + (*it)->updatePreviews(); +} + + int BufferList::bufferNum(FileName const & fname) const { - FileNameList const & buffers = fileNames(); + FileNameList const buffers(fileNames()); FileNameList::const_iterator cit = find(buffers.begin(), buffers.end(), fname); if (cit == buffers.end()) @@ -357,31 +386,6 @@ int BufferList::bufferNum(FileName const & fname) 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. - Buffer const * parent_ = child->parent(); - if (parent_ && 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; -} - - void BufferList::changed(bool update_metrics) const { BufferStorage::const_iterator it = bstore.begin();