]> git.lyx.org Git - features.git/commitdiff
Fix up a few little things after r29065. If we're calculating the autosave
authorRichard Heck <rgheck@comcast.net>
Sat, 4 Apr 2009 03:13:46 +0000 (03:13 +0000)
committerRichard Heck <rgheck@comcast.net>
Sat, 4 Apr 2009 03:13:46 +0000 (03:13 +0000)
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
src/Buffer.h
src/frontends/qt4/GuiView.cpp
src/support/filetools.cpp
src/support/filetools.h

index 48474c5f344916a143248b8014880b5cb3db297a..c5e70a7144a285532435b3d0fb5b3f1960980173 100644 (file)
@@ -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();
index f6543a8e8dfad214e5f6732cce6d8b258a789519..e50076f221f70a38173f8cb9903b0ae876455a4a 100644 (file)
@@ -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;
index 3f86deb70d1ffdcb9a74d9023d6fd460578555aa..02f143ce7d8ed9185f356a608e1c541e5ffea774 100644 (file)
@@ -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;
index f1f8429f7f29cafe2df42711291d082de86e39f7..37bc61e3a688c218ea303c743681d33cc9bcce7e 100644 (file)
@@ -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)
 {
index ec8ef17d4653a8c59c046c0a1199e176bcc96789..782ba2cc31773218b868d3441b116d849d3a1655 100644 (file)
@@ -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);