mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 13:31:49 +00:00
Fix bug #5879 (try 2): Move the autosave file of a buffer when the filename changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29507 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
11ecc24c0c
commit
aa4c7e7ef5
@ -2621,6 +2621,14 @@ void Buffer::removeAutosaveFile() const
|
||||
}
|
||||
|
||||
|
||||
void Buffer::moveAutosaveFile(support::FileName const & oldauto) const
|
||||
{
|
||||
FileName const newauto = getAutosaveFilename();
|
||||
if (!(oldauto == newauto || oldauto.moveTo(newauto)))
|
||||
LYXERR0("Unable to remove autosave file `" << oldauto << "'!");
|
||||
}
|
||||
|
||||
|
||||
// Perfect target for a thread...
|
||||
void Buffer::autoSave() const
|
||||
{
|
||||
|
@ -468,6 +468,10 @@ public:
|
||||
void autoSave() const;
|
||||
///
|
||||
void removeAutosaveFile() const;
|
||||
///
|
||||
void moveAutosaveFile(support::FileName const & old) const;
|
||||
///
|
||||
support::FileName getAutosaveFilename() const;
|
||||
|
||||
/// return the format of the buffer on a string
|
||||
std::string bufferFormat() const;
|
||||
@ -537,8 +541,6 @@ 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;
|
||||
|
@ -1818,6 +1818,8 @@ bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
|
||||
}
|
||||
}
|
||||
|
||||
FileName oldauto = b.getAutosaveFilename();
|
||||
|
||||
// Ok, change the name of the buffer
|
||||
b.setFileName(fname.absFilename());
|
||||
b.markDirty();
|
||||
@ -1825,10 +1827,15 @@ bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
|
||||
b.setUnnamed(false);
|
||||
b.saveCheckSum(fname);
|
||||
|
||||
// bring the autosave file with us, just in case.
|
||||
b.moveAutosaveFile(oldauto);
|
||||
|
||||
if (!saveBuffer(b)) {
|
||||
oldauto = b.getAutosaveFilename();
|
||||
b.setFileName(oldname.absFilename());
|
||||
b.setUnnamed(unnamed);
|
||||
b.saveCheckSum(oldname);
|
||||
b.moveAutosaveFile(oldauto);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user