X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferList.cpp;h=17b7aea9fa361129615b74e25178f0c4bfed78c3;hb=1712e4f35e3e8cb132f731dca773f7767a241bf6;hp=ecf7fdc4df54ca751a240d3de1b632a0e8f68bd8;hpb=c5487a368239775893ec4ac85cb81aaa477e0cc7;p=lyx.git diff --git a/src/BufferList.cpp b/src/BufferList.cpp index ecf7fdc4df..17b7aea9fa 100644 --- a/src/BufferList.cpp +++ b/src/BufferList.cpp @@ -32,12 +32,12 @@ #include "support/Package.h" #include "support/lassert.h" -#include +#include "support/bind.h" #include #include - -using boost::bind; +#include +#include using namespace std; using namespace lyx::support; @@ -119,7 +119,7 @@ Buffer * BufferList::newBuffer(string const & s, bool const ronly) } } tmpbuf->params().useClassDefaults(); - if (tmpbuf->fileName().extension() == "internal") { + if (tmpbuf->isInternal()) { binternal.push_back(tmpbuf.get()); } else { LYXERR(Debug::INFO, "Assigning to buffer " << bstore.size()); @@ -142,7 +142,7 @@ FileNameList const & BufferList::fileNames() const nvec.clear(); transform(bstore.begin(), bstore.end(), back_inserter(nvec), - boost::bind(&Buffer::fileName, _1)); + bind(&Buffer::fileName, _1)); return nvec; } @@ -232,8 +232,10 @@ 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; BufferStorage::const_iterator cit = find(bstore.begin(), bstore.end(), b); return cit != bstore.end(); @@ -253,12 +255,12 @@ Buffer * BufferList::getBuffer(support::FileName const & fname) const { // 1) cheap test, using string comparison of file names BufferStorage::const_iterator it = find_if(bstore.begin(), bstore.end(), - bind(equal_to(), bind(&Buffer::fileName, _1), fname)); + lyx::bind(equal_to(), lyx::bind(&Buffer::fileName, _1), fname)); if (it != bstore.end()) return *it; // 2) possibly expensive test, using equivalence test of file names it = find_if(bstore.begin(), bstore.end(), - bind(equivalent_to(), bind(&Buffer::fileName, _1), fname)); + lyx::bind(equivalent_to(), lyx::bind(&Buffer::fileName, _1), fname)); return it != bstore.end() ? (*it) : 0; } @@ -270,8 +272,7 @@ Buffer * BufferList::getBufferFromTmp(string const & s) for (; it < end; ++it) { if (prefixIs(s, (*it)->temppath())) { // check whether the filename matches the master - string const master_name = changeExtension(onlyFilename( - (*it)->absFileName()), ".tex"); + string const master_name = (*it)->latexName(); if (suffixIs(s, master_name)) return *it; // if not, try with the children @@ -281,7 +282,7 @@ Buffer * BufferList::getBufferFromTmp(string const & s) for (; cit < cend; ++cit) { string const mangled_child_name = DocFileName( changeExtension((*cit)->absFileName(), - ".tex")).mangledFilename(); + ".tex")).mangledFileName(); if (suffixIs(s, mangled_child_name)) return *cit; } @@ -318,7 +319,8 @@ bool BufferList::releaseChild(Buffer * parent, Buffer * child) LASSERT(parent->isChild(child), return false); // Child document has a different parent, don't close it. - if (child->parent() != parent) + Buffer const * parent_ = child->parent(); + if (parent_ && parent_ != parent) return false; BufferStorage::iterator it = bstore.begin(); @@ -335,4 +337,17 @@ bool BufferList::releaseChild(Buffer * parent, Buffer * child) } +void BufferList::changed(bool update_metrics) const +{ + BufferStorage::const_iterator it = bstore.begin(); + BufferStorage::const_iterator end = bstore.end(); + for (; it != end; ++it) + (*it)->changed(update_metrics); + it = binternal.begin(); + end = binternal.end(); + for (; it != end; ++it) + (*it)->changed(update_metrics); +} + + } // namespace lyx