mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
Return early again if there's nothing to do. Also, mark the buffer dirty
only if we manage to read the autosave file successfully. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35824 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1d55e97b2d
commit
5cd48620f1
@ -3661,22 +3661,27 @@ Buffer::ReadStatus Buffer::readAutosave(FileName const & fn)
|
|||||||
// Now check if autosave file is newer.
|
// Now check if autosave file is newer.
|
||||||
FileName const autosaveFile(onlyPath(fn.absFileName())
|
FileName const autosaveFile(onlyPath(fn.absFileName())
|
||||||
+ '#' + onlyFileName(fn.absFileName()) + '#');
|
+ '#' + onlyFileName(fn.absFileName()) + '#');
|
||||||
if (autosaveFile.exists()
|
if (!autosaveFile.exists()
|
||||||
&& autosaveFile.lastModified() > fn.lastModified()) {
|
|| autosaveFile.lastModified() <= fn.lastModified())
|
||||||
|
return ReadFileNotFound;
|
||||||
|
|
||||||
docstring const file = makeDisplayPath(fn.absFileName(), 20);
|
docstring const file = makeDisplayPath(fn.absFileName(), 20);
|
||||||
docstring const text =
|
docstring const text =
|
||||||
bformat(_("The backup of the document "
|
bformat(_("The backup of the document %1$s is newer.\n\n"
|
||||||
"%1$s is newer.\n\nLoad the "
|
"Load the backup instead?"), file);
|
||||||
"backup instead?"), file);
|
|
||||||
switch (Alert::prompt(_("Load backup?"), text, 0, 2,
|
switch (Alert::prompt(_("Load backup?"), text, 0, 2,
|
||||||
_("&Load backup"), _("Load &original"),
|
_("&Load backup"), _("Load &original"),
|
||||||
_("&Cancel") ))
|
_("&Cancel") ))
|
||||||
{
|
{
|
||||||
case 0:
|
case 0: {
|
||||||
|
bool success = readFile(autosaveFile);
|
||||||
// the file is not saved if we load the autosave file.
|
// the file is not saved if we load the autosave file.
|
||||||
|
if (success) {
|
||||||
markDirty();
|
markDirty();
|
||||||
return readFile(autosaveFile) ? ReadSuccess
|
return ReadSuccess;
|
||||||
: ReadAutosaveFailure;
|
}
|
||||||
|
return ReadAutosaveFailure;
|
||||||
|
}
|
||||||
case 1:
|
case 1:
|
||||||
// Here we delete the autosave
|
// Here we delete the autosave
|
||||||
autosaveFile.removeFile();
|
autosaveFile.removeFile();
|
||||||
@ -3684,8 +3689,8 @@ Buffer::ReadStatus Buffer::readAutosave(FileName const & fn)
|
|||||||
default:
|
default:
|
||||||
return ReadCancel;
|
return ReadCancel;
|
||||||
}
|
}
|
||||||
}
|
// suppress warning
|
||||||
return ReadFileNotFound;
|
return ReadCancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user