mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
Fix another prompt for externally-modified bug with writeAs()
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20107 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
7bf7a111b1
commit
726c8660f0
@ -756,8 +756,7 @@ Buffer::ReadStatus Buffer::readFile(Lexer & lex, FileName const & filename,
|
||||
string diskfile = filename.toFilesystemEncoding();
|
||||
if (suffixIs(diskfile, ".emergency"))
|
||||
diskfile = diskfile.substr(0, diskfile.size() - 10);
|
||||
pimpl_->timestamp_ = fs::last_write_time(diskfile);
|
||||
pimpl_->checksum_ = sum(FileName(diskfile));
|
||||
saveCheckSum(diskfile);
|
||||
}
|
||||
|
||||
if (file_format != LYX_FORMAT) {
|
||||
@ -874,8 +873,7 @@ bool Buffer::save() const
|
||||
if (writeFile(pimpl_->filename)) {
|
||||
markClean();
|
||||
removeAutosaveFile(fileName());
|
||||
pimpl_->timestamp_ = fs::last_write_time(pimpl_->filename.toFilesystemEncoding());
|
||||
pimpl_->checksum_ = sum(pimpl_->filename);
|
||||
saveCheckSum(pimpl_->filename.toFilesystemEncoding());
|
||||
return true;
|
||||
} else {
|
||||
// Saving failed, so backup is not backup
|
||||
@ -1634,6 +1632,19 @@ bool Buffer::isExternallyModified(CheckMethod method) const
|
||||
}
|
||||
|
||||
|
||||
void Buffer::saveCheckSum(string const & file) const
|
||||
{
|
||||
if (fs::exists(file)) {
|
||||
pimpl_->timestamp_ = fs::last_write_time(file);
|
||||
pimpl_->checksum_ = sum(FileName(file));
|
||||
} else {
|
||||
// in the case of save to a new file.
|
||||
pimpl_->timestamp_ = 0;
|
||||
pimpl_->checksum_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Buffer::markClean() const
|
||||
{
|
||||
if (!pimpl_->lyx_clean) {
|
||||
|
@ -229,6 +229,9 @@ public:
|
||||
/// whether or not disk file has been externally modified
|
||||
bool isExternallyModified(CheckMethod method) const;
|
||||
|
||||
/// save timestamp and checksum of the given file.
|
||||
void saveCheckSum(std::string const & file) const;
|
||||
|
||||
/// mark the main lyx file as not needing saving
|
||||
void markClean() const;
|
||||
|
||||
|
@ -195,10 +195,12 @@ bool writeAs(Buffer * buffer, string const & newname)
|
||||
buffer->markDirty();
|
||||
bool unnamed = buffer->isUnnamed();
|
||||
buffer->setUnnamed(false);
|
||||
buffer->saveCheckSum(fname);
|
||||
|
||||
if (!menuWrite(buffer)) {
|
||||
buffer->setFileName(oldname);
|
||||
buffer->setUnnamed(unnamed);
|
||||
buffer->saveCheckSum(oldname);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user