mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
Rename emergency file when it is kept.
Otherwise, we will ask about it again next time, when the file may have changed. Also, if we crash again, we'll over-write that file, which we may not want to do. See bug #11464.
This commit is contained in:
parent
a925d25085
commit
b804e8851c
@ -4770,6 +4770,32 @@ Buffer::ReadStatus Buffer::loadEmergency()
|
||||
_("&Remove"), _("&Keep"));
|
||||
if (del_emerg == 0)
|
||||
emergencyFile.removeFile();
|
||||
else {
|
||||
// See bug #11464
|
||||
FileName newname;
|
||||
string const ename = emergencyFile.absFileName();
|
||||
bool noname = true;
|
||||
// Surely we can find one in 100 tries?
|
||||
for (int i = 1; i < 100; ++i) {
|
||||
newname.set(ename + to_string(i) + ".lyx");
|
||||
if (!newname.exists()) {
|
||||
noname = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!noname) {
|
||||
// renameTo returns true on success. So inverting that
|
||||
// will give us true if we fail.
|
||||
noname = !emergencyFile.renameTo(newname);
|
||||
}
|
||||
if (noname) {
|
||||
Alert::warning(_("Can't rename emergency file!"),
|
||||
_("LyX was unable to rename the emergency file. "
|
||||
"You should do so manually. Otherwise, you will be"
|
||||
"asked about it again the next time you try to load"
|
||||
"this file, and may over-write your own work."));
|
||||
}
|
||||
}
|
||||
return ReadOriginal;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user