]> git.lyx.org Git - lyx.git/blobdiff - src/Buffer.cpp
Cmake export tests: Created sub-labels manuals, examples, templates, mathmacros,...
[lyx.git] / src / Buffer.cpp
index f907d6cdffed2254d59d74c7216e0a87e60c0b7f..eac9821e9fa3d55a47f1cdac6cfad6125735cfe2 100644 (file)
@@ -1306,7 +1306,7 @@ Buffer::ReadStatus Buffer::convertLyXFormat(FileName const & fn,
 }
 
 
-string Buffer::getBackupName() const {
+FileName Buffer::getBackupName() const {
        FileName const & fn = fileName();
        string const fname = fn.onlyFileNameWithoutExt();
        string const fext  = fn.extension();
@@ -1333,11 +1333,11 @@ string Buffer::getBackupName() const {
                        v = 1000;
                        break;
                }
-               string newbackname = backname + "-" + convert<string>(v);
+               string const newbackname = backname + "-" + convert<string>(v);
                backup.set(addName(fpath, addExtension(newbackname, fext)));
                v++;
        }
-       return v < 100 ? backup.absFileName() : "";
+       return v < 100 ? backup : FileName();
 }
 
 
@@ -1401,12 +1401,10 @@ bool Buffer::save() const
        bool made_backup = true;
 
        FileName backupName;
-       if (lyxrc.make_backup || d->need_format_backup) {
-               if (d->need_format_backup) {
-                       string backup_name = getBackupName();
-                       if (!backup_name.empty())
-                               backupName.set(backup_name);
-               }
+       bool const needBackup = lyxrc.make_backup || d->need_format_backup;
+       if (needBackup) {
+               if (d->need_format_backup)
+                       backupName = getBackupName();
 
                // If we for some reason failed to find a backup name in case of
                // a format change, this will still set one. It's the best we can
@@ -1461,8 +1459,8 @@ bool Buffer::save() const
        }
        // else we saved the file, but failed to move it to the right location.
 
-       if (lyxrc.make_backup && made_backup && !symlink) {
-               // the original file was moved to filename.lyx~, so it will look
+       if (needBackup && made_backup && !symlink) {
+               // the original file was moved to some new location, so it will look
                // to the user as if it was deleted. (see bug #9234.) we could try
                // to restore it, but that would basically mean trying to do again
                // what we just failed to do. better to leave things as they are.