The branch, master, has been updated. - Log -----------------------------------------------------------------
commit 6cf1847b31617cd2ad190919d0ceaa51e1601ad8 Author: Vincent van Ravesteijn <[email protected]> Date: Sat May 12 14:11:56 2012 +0200 New function BufferList::newInternalBuffer This solves the problem that newBuffer() already use Buffer::isInternal but there was no chance to set it yet. diff --git a/src/BufferList.cpp b/src/BufferList.cpp index c107862..a5c4b42 100644 --- a/src/BufferList.cpp +++ b/src/BufferList.cpp @@ -104,8 +104,30 @@ void BufferList::release(Buffer * buf) } +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)); @@ -119,12 +141,6 @@ Buffer * BufferList::newBuffer(string const & s) } } 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(); } diff --git a/src/BufferList.h b/src/BufferList.h index 2e4258c..95df26a 100644 --- a/src/BufferList.h +++ b/src/BufferList.h @@ -47,10 +47,14 @@ public: iterator end(); const_iterator end() const; - /// create a new buffer + /// create a new buffer and add it to the buffer list /// \return 0 if the Buffer creation is not possible for whatever reason. Buffer * newBuffer(std::string const & s); + /// create an internal buffer and add it to the internal buffer list + /// \return 0 if the Buffer creation is not possible for whatever reason. + Buffer * newInternalBuffer(std::string const & s); + /// delete a buffer void release(Buffer * b); @@ -120,6 +124,10 @@ public: //@} private: + /// create a new buffer + /// \return 0 if the Buffer creation is not possible for whatever reason. + Buffer * createNewBuffer(std::string const & s); + /// noncopiable BufferList(BufferList const &); void operator=(BufferList const &); diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index 2bd1be4..f60579b 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -470,9 +470,8 @@ void putClipboard(ParagraphList const & paragraphs, // a DocumentClass, via new, that is never deleted. If we were to go to // some kind of garbage collection there, or a shared_ptr, then this // would not be needed. - static Buffer * buffer = theBufferList().newBuffer( + static Buffer * buffer = theBufferList().newInternalBuffer( FileName::tempName("clipboard.internal").absFileName()); - buffer->setInternal(true); buffer->setUnnamed(true); buffer->paragraphs() = paragraphs; buffer->inset().setBuffer(*buffer); diff --git a/src/frontends/qt4/GuiWorkArea.cpp b/src/frontends/qt4/GuiWorkArea.cpp index 346295d..5eca896 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -1414,9 +1414,8 @@ GuiView & GuiWorkArea::view() EmbeddedWorkArea::EmbeddedWorkArea(QWidget * w): GuiWorkArea(w) { - buffer_ = theBufferList().newBuffer( + buffer_ = theBufferList().newInternalBuffer( support::FileName::tempName("embedded.internal").absFileName()); - buffer_->setInternal(true); buffer_->setUnnamed(true); buffer_->setFullyLoaded(true); setBuffer(*buffer_); commit fa438c1699ae0e4eec669b039162f7d56114ccda Author: Vincent van Ravesteijn <[email protected]> Date: Sat May 12 13:54:20 2012 +0200 Remove read_only parameter from newBuffer This parameter defaults to false and it is never set to true. So, we can better remove the parameter. diff --git a/src/BufferList.cpp b/src/BufferList.cpp index c0700b4..c107862 100644 --- a/src/BufferList.cpp +++ b/src/BufferList.cpp @@ -104,11 +104,11 @@ void BufferList::release(Buffer * buf) } -Buffer * BufferList::newBuffer(string const & s, bool const ronly) +Buffer * BufferList::newBuffer(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_); diff --git a/src/BufferList.h b/src/BufferList.h index b721386..2e4258c 100644 --- a/src/BufferList.h +++ b/src/BufferList.h @@ -49,7 +49,7 @@ public: /// create a new buffer /// \return 0 if the Buffer creation is not possible for whatever reason. - Buffer * newBuffer(std::string const & s, bool ronly = false); + Buffer * newBuffer(std::string const & s); /// delete a buffer void release(Buffer * b); diff --git a/src/LyX.cpp b/src/LyX.cpp index 7e56d55..6b46066 100644 --- a/src/LyX.cpp +++ b/src/LyX.cpp @@ -511,7 +511,7 @@ bool LyX::loadFiles() if (fname.empty()) continue; - Buffer * buf = pimpl_->buffer_list_.newBuffer(fname.absFileName(), false); + Buffer * buf = pimpl_->buffer_list_.newBuffer(fname.absFileName()); if (buf->loadLyXFile() == Buffer::ReadSuccess) { ErrorList const & el = buf->errorList("Parse"); if (!el.empty()) ----------------------------------------------------------------------- Summary of changes: src/BufferList.cpp | 32 ++++++++++++++++++++++++-------- src/BufferList.h | 12 ++++++++++-- src/CutAndPaste.cpp | 3 +-- src/LyX.cpp | 2 +- src/frontends/qt4/GuiWorkArea.cpp | 3 +-- 5 files changed, 37 insertions(+), 15 deletions(-) hooks/post-receive -- The LyX Source Repository
