From 1ae948e136bd78510719e806e0751e02d9d99642 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Sat, 3 Dec 2011 23:20:18 +0000 Subject: [PATCH] Fix #7923: Don't clone all the children on autosave. We split Buffer::clone() into various routines that know whether to clone the children. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40357 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 16 ++++++++++++---- src/Buffer.h | 9 ++++++--- src/frontends/qt4/GuiView.cpp | 4 ++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index ae3e294ff7..af66521f9f 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -462,13 +462,13 @@ Buffer::~Buffer() } -Buffer * Buffer::clone() const +Buffer * Buffer::cloneFromMaster() const { BufferMap bufmap; cloned_buffers.push_back(new CloneList()); CloneList * clones = cloned_buffers.back(); - masterBuffer()->clone(bufmap, clones); + masterBuffer()->cloneWithChildren(bufmap, clones); // make sure we got cloned BufferMap::const_iterator bit = bufmap.find(this); @@ -479,7 +479,7 @@ Buffer * Buffer::clone() const } -void Buffer::clone(BufferMap & bufmap, CloneList * clones) const +void Buffer::cloneWithChildren(BufferMap & bufmap, CloneList * clones) const { // have we already been cloned? if (bufmap.find(this) != bufmap.end()) @@ -502,7 +502,7 @@ void Buffer::clone(BufferMap & bufmap, CloneList * clones) const dit.setBuffer(buffer_clone); Buffer * child = const_cast(it->second.second); - child->clone(bufmap, clones); + child->cloneWithChildren(bufmap, clones); BufferMap::iterator const bit = bufmap.find(child); LASSERT(bit != bufmap.end(), continue); Buffer * child_clone = bit->second; @@ -520,6 +520,14 @@ void Buffer::clone(BufferMap & bufmap, CloneList * clones) const } +Buffer * Buffer::cloneBufferOnly() const { + Buffer * buffer_clone = new Buffer(fileName().absFileName(), false, this); + // we won't be cloning the children + buffer_clone->d->children_positions.clear(); + return buffer_clone; +} + + bool Buffer::isClone() const { return d->cloned_buffer_; diff --git a/src/Buffer.h b/src/Buffer.h index 62e03a4652..f8bd784fce 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -168,8 +168,11 @@ public: /// Destructor ~Buffer(); - /// - Buffer * clone() const; + /// Clones the entire structure of which this Buffer is part, starting + /// with the master and cloning all the children, too. + Buffer * cloneFromMaster() const; + /// Just clones this single Buffer. For autosave. + Buffer * cloneBufferOnly() const; /// bool isClone() const; @@ -232,7 +235,7 @@ private: /// typedef std::map BufferMap; /// - void clone(BufferMap &, CloneList *) const; + void cloneWithChildren(BufferMap &, CloneList *) const; /// save timestamp and checksum of the given file. void saveCheckSum() const; /// read a new file diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 2409823008..48bbc056b6 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -1575,7 +1575,7 @@ void GuiView::autoSave() #if (QT_VERSION >= 0x040400) GuiViewPrivate::busyBuffers.insert(buffer); QFuture f = QtConcurrent::run(GuiViewPrivate::autosaveAndDestroy, - buffer, buffer->clone()); + buffer, buffer->cloneBufferOnly()); d.autosave_watcher_.setFuture(f); #else buffer->autoSave(); @@ -3122,7 +3122,7 @@ bool GuiView::GuiViewPrivate::asyncBufferProcessing( QFuture f = QtConcurrent::run( asyncFunc, used_buffer, - used_buffer->clone(), + used_buffer->cloneFromMaster(), format); setPreviewFuture(f); last_export_format = used_buffer->params().bufferFormat(); -- 2.39.2