From 876dc0d54e02c18df53ef392da6a4504657834c0 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Sat, 4 Apr 2009 03:13:46 +0000 Subject: [PATCH] Fix up a few little things after r29065. If we're calculating the autosave filename in a different way, we need to make sure we always do it the same way. Makes more sense to do this in Buffer anyway. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29073 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 26 ++++++++++++++++++-------- src/Buffer.h | 4 ++++ src/frontends/qt4/GuiView.cpp | 2 +- src/support/filetools.cpp | 12 ------------ src/support/filetools.h | 3 --- 5 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 48474c5f34..c5e70a7144 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -930,7 +930,7 @@ bool Buffer::writeFile(FileName const & fname) const return false; } - removeAutosaveFile(d->filename.absFilename()); + removeAutosaveFile(); saveCheckSum(d->filename); message(str + _(" done.")); @@ -2423,6 +2423,22 @@ int AutoSaveBuffer::generateChild() } // namespace anon +FileName Buffer::getAutosaveFilename() const +{ + string const fpath = isUnnamed() ? lyxrc.document_path : filePath(); + string const fname = "#" + d->filename.onlyFileName() + "#"; + return makeAbsPath(fname, fpath); +} + + +void Buffer::removeAutosaveFile() const +{ + FileName const f = getAutosaveFilename(); + if (f.exists()) + f.removeFile(); +} + + // Perfect target for a thread... void Buffer::autoSave() const { @@ -2434,13 +2450,7 @@ void Buffer::autoSave() const // emit message signal. message(_("Autosaving current document...")); - - // create autosave filename - string fpath = isUnnamed() ? lyxrc.document_path : filePath(); - string fname = "#" + d->filename.onlyFileName() + "#"; - FileName file_name = makeAbsPath(fname, fpath); - - AutoSaveBuffer autosave(*this, file_name); + AutoSaveBuffer autosave(*this, getAutosaveFilename()); autosave.start(); markBakClean(); diff --git a/src/Buffer.h b/src/Buffer.h index f6543a8e8d..e50076f221 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -456,6 +456,8 @@ public: /// void autoSave() const; + /// + void removeAutosaveFile() const; /// return the format of the buffer on a string std::string bufferFormat() const; @@ -520,6 +522,8 @@ private: */ ReadStatus readFile(Lexer &, support::FileName const & filename, bool fromString = false); + /// + support::FileName getAutosaveFilename() const; /// Use the Pimpl idiom to hide the internals. class Impl; diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 3f86deb70d..02f143ce7d 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -1908,7 +1908,7 @@ bool GuiView::closeBuffer(Buffer & buf, bool tolastopened) // if we crash after this we could // have no autosave file but I guess // this is really improbable (Jug) - removeAutosaveFile(buf.absFileName()); + buf.removeAutosaveFile(); break; case 2: return false; diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp index f1f8429f7f..37bc61e3a6 100644 --- a/src/support/filetools.cpp +++ b/src/support/filetools.cpp @@ -837,18 +837,6 @@ FileName const findtexfile(string const & fil, string const & /*format*/) } -void removeAutosaveFile(string const & filename) -{ - string a = onlyPath(filename); - a += '#'; - a += onlyFilename(filename); - a += '#'; - FileName const autosave(a); - if (autosave.exists()) - autosave.removeFile(); -} - - void readBB_lyxerrMessage(FileName const & file, bool & zipped, string const & message) { diff --git a/src/support/filetools.h b/src/support/filetools.h index ec8ef17d46..782ba2cc31 100644 --- a/src/support/filetools.h +++ b/src/support/filetools.h @@ -250,9 +250,6 @@ bool readLink(FileName const & file, FileName & link); FileName const findtexfile(std::string const & fil, std::string const & format); -/// remove the autosave-file and give a Message if it can't be done -void removeAutosaveFile(std::string const & filename); - /// read the BoundingBox entry from a ps/eps/pdf-file std::string const readBB_from_PSFile(FileName const & file); -- 2.39.5