Fix bug #5879: Move the autosave file of a buffer when the filename changes (patch by Richard).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29505 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2009-05-03 09:09:33 +00:00
parent 3045d9b4ff
commit dce037ed5a

View File

@ -491,9 +491,17 @@ void Buffer::setReadonly(bool const flag)
void Buffer::setFileName(string const & newfile)
{
// bring the autosave file with us, just in case.
FileName const oldauto = getAutosaveFilename();
d->filename = makeAbsPath(newfile);
setReadonly(d->filename.isReadOnly());
updateTitles();
FileName const newauto = getAutosaveFilename();
if (oldauto == newauto)
return;
if (oldauto.moveTo(newauto))
return;
LYXERR0("Unable to remove autosave file `" << oldauto << "'!");
}