X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FBufferList.cpp;h=9a5c4e1c27bef836a145ebcb156c64c14a497c2c;hb=57b69a5efddf9f3c148007322f00dad6c253a2ed;hp=68a1e808cb07ab98672b4f5a49185e7dba0f4f05;hpb=390ae05444cf4899a3028dcbbfe1095ecd2d207a;p=lyx.git diff --git a/src/BufferList.cpp b/src/BufferList.cpp index 68a1e808cb..9a5c4e1c27 100644 --- a/src/BufferList.cpp +++ b/src/BufferList.cpp @@ -130,9 +130,9 @@ Buffer * BufferList::newBuffer(string const & s) Buffer * BufferList::createNewBuffer(string const & s) { - auto_ptr tmpbuf; + unique_ptr tmpbuf; try { - tmpbuf.reset(new Buffer(s)); + tmpbuf = make_unique(s); } catch (ExceptionMessage const & message) { if (message.type_ == ErrorException) { Alert::error(message.title_, message.details_); @@ -267,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 @@ -364,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();