}
-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);
}
-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())
dit.setBuffer(buffer_clone);
Buffer * child = const_cast<Buffer *>(it->second.second);
- child->clone(bufmap, clones);
- BufferMap::iterator it = bufmap.find(child);
- LASSERT(it != bufmap.end(), continue);
- Buffer * child_clone = it->second;
+ child->cloneWithChildren(bufmap, clones);
+ BufferMap::iterator const bit = bufmap.find(child);
+ LASSERT(bit != bufmap.end(), continue);
+ Buffer * child_clone = bit->second;
Inset * inset = dit.nextInset();
LASSERT(inset && inset->lyxCode() == INCLUDE_CODE, continue);
}
+Buffer * Buffer::cloneBufferOnly() const {
+ cloned_buffers.push_back(new CloneList());
+ CloneList * clones = cloned_buffers.back();
+ Buffer * buffer_clone = new Buffer(fileName().absFileName(), false, this);
+ clones->insert(buffer_clone);
+ buffer_clone->d->clone_list_ = clones;
+ // we won't be cloning the children
+ buffer_clone->d->children_positions.clear();
+ return buffer_clone;
+}
+
+
bool Buffer::isClone() const
{
return d->cloned_buffer_;
/// 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;
///
typedef std::map<Buffer const *, Buffer *> 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
#if (QT_VERSION >= 0x040400)
GuiViewPrivate::busyBuffers.insert(buffer);
QFuture<docstring> f = QtConcurrent::run(GuiViewPrivate::autosaveAndDestroy,
- buffer, buffer->clone());
+ buffer, buffer->cloneBufferOnly());
d.autosave_watcher_.setFuture(f);
#else
buffer->autoSave();
QFuture<docstring> f = QtConcurrent::run(
asyncFunc,
used_buffer,
- used_buffer->clone(),
+ used_buffer->cloneFromMaster(),
format);
setPreviewFuture(f);
last_export_format = used_buffer->params().bufferFormat();