From 1f38406536903850c8ef0581833fabbec38f5d71 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Thu, 18 Nov 2010 17:50:33 +0000 Subject: [PATCH] Buffer::setFileName() can now be private. The only way to change the filename of a buffer is to save it as a different file using Buffer::saveAs(). Change its parameter type to support::FileName for convenience. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36375 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 10 +++++----- src/Buffer.h | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 26126da838..0127721761 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -189,7 +189,7 @@ public: /// is autosave needed? mutable bool bak_clean; - /// is this a unnamed file (New...)? + /// is this an unnamed file (New...)? bool unnamed; /// buffer is r/o @@ -642,9 +642,9 @@ void Buffer::setReadonly(bool const flag) } -void Buffer::setFileName(string const & newfile) +void Buffer::setFileName(FileName const & fname) { - d->filename = makeAbsPath(newfile); + d->filename = fname; setReadonly(d->filename.isReadOnly()); updateTitles(); } @@ -4145,7 +4145,7 @@ bool Buffer::saveAs(FileName const & fn) FileName const old_auto = getAutosaveFileName(); bool const old_unnamed = isUnnamed(); - setFileName(fn.absFileName()); + setFileName(fn); markDirty(); setUnnamed(false); @@ -4164,7 +4164,7 @@ bool Buffer::saveAs(FileName const & fn) } else { // save failed // reset the old filename and unnamed state - setFileName(old_name.absFileName()); + setFileName(old_name); setUnnamed(old_unnamed); saveCheckSum(); return false; diff --git a/src/Buffer.h b/src/Buffer.h index 3cc0452ac9..03710c7a0f 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -365,9 +365,6 @@ public: /// Get the name and type of the log. std::string logName(LogType * type = 0) const; - /// Change name of buffer. Updates "read-only" flag. - void setFileName(std::string const & newfile); - /// Set document's parent Buffer. void setParent(Buffer const *); Buffer const * parent() const; @@ -657,6 +654,8 @@ public: void checkChildBuffers(); private: + /// Change name of buffer. Updates "read-only" flag. + void setFileName(support::FileName const & fname); /// std::vector backends() const; ///