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.
This commit is contained in:
Vincent van Ravesteijn 2012-05-06 20:06:28 +02:00
parent cd691081b4
commit 5279d5a8a5
4 changed files with 21 additions and 6 deletions

View File

@ -195,6 +195,9 @@ public:
/// is this an unnamed file (New...)? /// is this an unnamed file (New...)?
bool unnamed; bool unnamed;
/// is this an internal bufffer?
bool internal_buffer;
/// buffer is r/o /// buffer is r/o
bool read_only; bool read_only;
@ -355,11 +358,12 @@ static FileName createBufferTmpDir()
Buffer::Impl::Impl(Buffer * owner, FileName const & file, bool readonly_, Buffer::Impl::Impl(Buffer * owner, FileName const & file, bool readonly_,
Buffer const * cloned_buffer) Buffer const * cloned_buffer)
: owner_(owner), lyx_clean(true), bak_clean(true), unnamed(false), : owner_(owner), lyx_clean(true), bak_clean(true), unnamed(false),
read_only(readonly_), filename(file), file_fully_loaded(false), internal_buffer(false), read_only(readonly_), filename(file),
toc_backend(owner), macro_lock(false), timestamp_(0), checksum_(0), file_fully_loaded(false), toc_backend(owner), macro_lock(false),
wa_(0), gui_(0), undo_(*owner), bibinfo_cache_valid_(false), timestamp_(0), checksum_(0), wa_(0), gui_(0), undo_(*owner),
bibfile_cache_valid_(false), cite_labels_valid_(false), bibinfo_cache_valid_(false), bibfile_cache_valid_(false),
preview_loader_(0), cloned_buffer_(cloned_buffer), clone_list_(0), cite_labels_valid_(false), preview_loader_(0),
cloned_buffer_(cloned_buffer), clone_list_(0),
doing_export(false), parent_buffer(0) doing_export(false), parent_buffer(0)
{ {
if (!cloned_buffer_) { if (!cloned_buffer_) {
@ -379,6 +383,7 @@ Buffer::Impl::Impl(Buffer * owner, FileName const & file, bool readonly_,
bibfile_status_ = cloned_buffer_->d->bibfile_status_; bibfile_status_ = cloned_buffer_->d->bibfile_status_;
cite_labels_valid_ = cloned_buffer_->d->cite_labels_valid_; cite_labels_valid_ = cloned_buffer_->d->cite_labels_valid_;
unnamed = cloned_buffer_->d->unnamed; 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. /// retrieving fileName() nor for checking if it is unnamed or not.
bool Buffer::isInternal() const bool Buffer::isInternal() const
{ {
return fileName().extension() == "internal"; return d->internal_buffer;
}
void Buffer::setInternal(bool flag)
{
d->internal_buffer = flag;
} }

View File

@ -379,6 +379,8 @@ public:
/// automatically saved, nor it needs to trigger any "do you want to save ?" question. /// automatically saved, nor it needs to trigger any "do you want to save ?" question.
bool isInternal() const; bool isInternal() const;
void setInternal(bool flag);
/// Mark this buffer as dirty. /// Mark this buffer as dirty.
void markDirty(); void markDirty();

View File

@ -472,6 +472,7 @@ void putClipboard(ParagraphList const & paragraphs,
// would not be needed. // would not be needed.
static Buffer * buffer = theBufferList().newBuffer( static Buffer * buffer = theBufferList().newBuffer(
FileName::tempName("clipboard.internal").absFileName()); FileName::tempName("clipboard.internal").absFileName());
buffer->setInternal(true);
buffer->setUnnamed(true); buffer->setUnnamed(true);
buffer->paragraphs() = paragraphs; buffer->paragraphs() = paragraphs;
buffer->inset().setBuffer(*buffer); buffer->inset().setBuffer(*buffer);

View File

@ -1416,6 +1416,7 @@ EmbeddedWorkArea::EmbeddedWorkArea(QWidget * w): GuiWorkArea(w)
{ {
buffer_ = theBufferList().newBuffer( buffer_ = theBufferList().newBuffer(
support::FileName::tempName("embedded.internal").absFileName()); support::FileName::tempName("embedded.internal").absFileName());
buffer_->setInternal(true);
buffer_->setUnnamed(true); buffer_->setUnnamed(true);
buffer_->setFullyLoaded(true); buffer_->setFullyLoaded(true);
setBuffer(*buffer_); setBuffer(*buffer_);