]> git.lyx.org Git - lyx.git/blobdiff - src/BufferList.cpp
make \lyxadded and \lyxdeleted robust (#8435)
[lyx.git] / src / BufferList.cpp
index 5143c1312666886941c88c782148ffde38847ce4..2348ac610348b28d96634f877a79a87bfefa7962 100644 (file)
@@ -104,11 +104,33 @@ void BufferList::release(Buffer * buf)
 }
 
 
-Buffer * BufferList::newBuffer(string const & s, bool const ronly)
+Buffer * BufferList::newInternalBuffer(string const & s)
+{
+       Buffer * const buf = createNewBuffer(s);
+       if (buf) {
+               buf->setInternal(true);
+               binternal.push_back(buf);
+       }
+       return buf;
+}
+
+
+Buffer * BufferList::newBuffer(string const & s)
+{
+       Buffer * const buf = createNewBuffer(s);
+       if (buf) {
+               LYXERR(Debug::INFO, "Assigning to buffer " << bstore.size());
+               bstore.push_back(buf);
+       }
+       return buf;
+}
+
+
+Buffer * BufferList::createNewBuffer(string const & s)
 {
        auto_ptr<Buffer> tmpbuf;
        try {
-               tmpbuf.reset(new Buffer(s, ronly));
+               tmpbuf.reset(new Buffer(s));
        } catch (ExceptionMessage const & message) {
                if (message.type_ == ErrorException) {
                        Alert::error(message.title_, message.details_);
@@ -119,12 +141,6 @@ Buffer * BufferList::newBuffer(string const & s, bool const ronly)
                }
        }
        tmpbuf->params().useClassDefaults();
-       if (tmpbuf->isInternal()) {
-               binternal.push_back(tmpbuf.get());
-       } else {
-               LYXERR(Debug::INFO, "Assigning to buffer " << bstore.size());
-               bstore.push_back(tmpbuf.get());
-       }
        return tmpbuf.release();
 }
 
@@ -180,8 +196,8 @@ Buffer * BufferList::next(Buffer const * buf) const
 
        if (bstore.empty())
                return 0;
-       BufferStorage::const_iterator it = find(bstore.begin(),
-                                               bstore.end(), buf);
+       BufferStorage::const_iterator it = 
+                       find(bstore.begin(), bstore.end(), buf);
        LASSERT(it != bstore.end(), /**/);
        ++it;
        Buffer * nextbuf = (it == bstore.end()) ? bstore.front() : *it;
@@ -195,8 +211,8 @@ Buffer * BufferList::previous(Buffer const * buf) const
 
        if (bstore.empty())
                return 0;
-       BufferStorage::const_iterator it = find(bstore.begin(),
-                                               bstore.end(), buf);
+       BufferStorage::const_iterator it = 
+                       find(bstore.begin(), bstore.end(), buf);
        LASSERT(it != bstore.end(), /**/);
 
        Buffer * previousbuf = (it == bstore.begin()) ? bstore.back() : *(it - 1);
@@ -205,8 +221,10 @@ Buffer * BufferList::previous(Buffer const * buf) const
 
 
 void BufferList::updateIncludedTeXfiles(string const & masterTmpDir,
-                                       OutputParams const & runparams)
+                                       OutputParams const & runparams_in)
 {
+       OutputParams runparams = runparams_in;
+       runparams.is_child = true;
        BufferStorage::iterator it = bstore.begin();
        BufferStorage::iterator end = bstore.end();
        for (; it != end; ++it) {
@@ -217,6 +235,7 @@ void BufferList::updateIncludedTeXfiles(string const & masterTmpDir,
                        (*it)->markDepClean(masterTmpDir);
                }
        }
+       runparams.is_child = false;
 }
 
 
@@ -246,11 +265,13 @@ bool BufferList::exists(FileName const & fname) const
 
 
 namespace {
+
 struct equivalent_to : public binary_function<FileName, FileName, bool>
 {
        bool operator()(FileName const & x, FileName const & y) const
        { return equivalent(x, y); }
 };
+
 }