From 22204cda0ba93d0ae4b79418315a159962517309 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 13 Oct 2008 20:40:58 +0000 Subject: [PATCH] Fix bug http://bugzilla.lyx.org/show_bug.cgi?id=5355 The mixing of internal and 'normal' buffers turned out to be problematic. This commit just dissociates the two types. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26884 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 5 +++++ src/BufferList.cpp | 21 +++++++++++++++------ src/BufferList.h | 3 +++ src/frontends/qt4/Menus.cpp | 5 ----- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 3f1843cb59..7358872b0b 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -277,6 +277,11 @@ Buffer::~Buffer() // GuiView already destroyed gui_ = 0; + if (d->unnamed && d->filename.extension() == "internal") { + // No need to do additional cleanups for internal buffer. + delete d; + return; + } // loop over children Impl::BufferPositionMap::iterator it = d->children_positions.begin(); diff --git a/src/BufferList.cpp b/src/BufferList.cpp index 867d081c3f..4f7c4e0ac4 100644 --- a/src/BufferList.cpp +++ b/src/BufferList.cpp @@ -51,6 +51,15 @@ BufferList::BufferList() {} +BufferList::~BufferList() +{ + BufferStorage::iterator it = binternal.begin(); + BufferStorage::iterator end = binternal.end(); + for (; it != end; ++it) + delete (*it); +} + + bool BufferList::empty() const { return bstore.empty(); @@ -110,8 +119,12 @@ Buffer * BufferList::newBuffer(string const & s, bool const ronly) } } tmpbuf->params().useClassDefaults(); - LYXERR(Debug::INFO, "Assigning to buffer " << bstore.size()); - bstore.push_back(tmpbuf.get()); + if (tmpbuf->fileName().extension() == "internal") { + binternal.push_back(tmpbuf.get()); + } else { + LYXERR(Debug::INFO, "Assigning to buffer " << bstore.size()); + bstore.push_back(tmpbuf.get()); + } return tmpbuf.release(); } @@ -169,8 +182,6 @@ Buffer * BufferList::next(Buffer const * buf) const LASSERT(it != bstore.end(), /**/); ++it; Buffer * nextbuf = (it == bstore.end()) ? bstore.front() : *it; - if (nextbuf->fileName().extension() == "internal") - return next(nextbuf); return nextbuf; } @@ -186,8 +197,6 @@ Buffer * BufferList::previous(Buffer const * buf) const LASSERT(it != bstore.end(), /**/); Buffer * previousbuf = (it == bstore.begin()) ? bstore.back() : *(it - 1); - if (previousbuf->fileName().extension() == "internal") - return previous(previousbuf); return previousbuf; } diff --git a/src/BufferList.h b/src/BufferList.h index a7a5e168c5..8c79d4c30a 100644 --- a/src/BufferList.h +++ b/src/BufferList.h @@ -38,6 +38,7 @@ public: public: BufferList(); + ~BufferList(); iterator begin(); const_iterator begin() const; @@ -122,6 +123,8 @@ private: /// storage of all buffers BufferStorage bstore; + /// storage of all internal buffers used for cut&paste, etc. + BufferStorage binternal; }; /// Implementation is in LyX.cpp diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index d532c9b801..48d3bfe701 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -680,11 +680,6 @@ void MenuDefinition::expandDocuments() // We cannot use a for loop as the buffer list cycles. do { QString label = toqstr(b->fileName().displayName(20)); - if (b->isUnnamed() && label.endsWith(".internal")) { - // This is an internal Buffer (eg. for clipboard operations) - b = theBufferList().next(b); - continue; - } if (!b->isClean()) label += "*"; if (ii < 10) -- 2.39.5