From 5279d5a8a58b9e59442b9f3f504ea397274e2b19 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Sun, 6 May 2012 20:06:28 +0200 Subject: [PATCH] Properly mark a buffer as internal Checking the extension of the temporary filename doesn't work anymore since the naming of temporary files was corrected. --- src/Buffer.cpp | 23 +++++++++++++++++------ src/Buffer.h | 2 ++ src/CutAndPaste.cpp | 1 + src/frontends/qt4/GuiWorkArea.cpp | 1 + 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 0ac4f45d48..1dc5d592e5 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -195,6 +195,9 @@ public: /// is this an unnamed file (New...)? bool unnamed; + /// is this an internal bufffer? + bool internal_buffer; + /// buffer is r/o bool read_only; @@ -355,11 +358,12 @@ static FileName createBufferTmpDir() Buffer::Impl::Impl(Buffer * owner, FileName const & file, bool readonly_, Buffer const * cloned_buffer) : owner_(owner), lyx_clean(true), bak_clean(true), unnamed(false), - read_only(readonly_), filename(file), file_fully_loaded(false), - toc_backend(owner), macro_lock(false), timestamp_(0), checksum_(0), - wa_(0), gui_(0), undo_(*owner), bibinfo_cache_valid_(false), - bibfile_cache_valid_(false), cite_labels_valid_(false), - preview_loader_(0), cloned_buffer_(cloned_buffer), clone_list_(0), + internal_buffer(false), read_only(readonly_), filename(file), + file_fully_loaded(false), toc_backend(owner), macro_lock(false), + timestamp_(0), checksum_(0), wa_(0), gui_(0), undo_(*owner), + bibinfo_cache_valid_(false), bibfile_cache_valid_(false), + cite_labels_valid_(false), preview_loader_(0), + cloned_buffer_(cloned_buffer), clone_list_(0), doing_export(false), parent_buffer(0) { if (!cloned_buffer_) { @@ -379,6 +383,7 @@ Buffer::Impl::Impl(Buffer * owner, FileName const & file, bool readonly_, bibfile_status_ = cloned_buffer_->d->bibfile_status_; cite_labels_valid_ = cloned_buffer_->d->cite_labels_valid_; unnamed = cloned_buffer_->d->unnamed; + internal_buffer = cloned_buffer_->d->internal_buffer; } @@ -2668,7 +2673,13 @@ bool Buffer::isUnnamed() const /// retrieving fileName() nor for checking if it is unnamed or not. bool Buffer::isInternal() const { - return fileName().extension() == "internal"; + return d->internal_buffer; +} + + +void Buffer::setInternal(bool flag) +{ + d->internal_buffer = flag; } diff --git a/src/Buffer.h b/src/Buffer.h index 8bf1417d8b..3c4d0f40d0 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -379,6 +379,8 @@ public: /// automatically saved, nor it needs to trigger any "do you want to save ?" question. bool isInternal() const; + void setInternal(bool flag); + /// Mark this buffer as dirty. void markDirty(); diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index 8b0142a20f..2bd1be48c1 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -472,6 +472,7 @@ void putClipboard(ParagraphList const & paragraphs, // would not be needed. static Buffer * buffer = theBufferList().newBuffer( 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 4a5dae1c78..346295d370 100644 --- a/src/frontends/qt4/GuiWorkArea.cpp +++ b/src/frontends/qt4/GuiWorkArea.cpp @@ -1416,6 +1416,7 @@ EmbeddedWorkArea::EmbeddedWorkArea(QWidget * w): GuiWorkArea(w) { buffer_ = theBufferList().newBuffer( support::FileName::tempName("embedded.internal").absFileName()); + buffer_->setInternal(true); buffer_->setUnnamed(true); buffer_->setFullyLoaded(true); setBuffer(*buffer_);