Jurgen, Attached please find a patch that combines r19916/trunk and a fix for bug 4193. Briefly speaking, when an emergency file is loaded, its timestamp and sum are saved, but isExternallyModified will compare them with the timestamp and sum of the original file. Therefore, a 'file is externally modified' will always display when the emergency file is loaded and saved. The patch saves timestamp and sum of the original file in this case.
To test: 1. copy FAQ.lyx to FAQ.lyx.emergency 2. modify FAQ.lyx.emergency a little bit 3. open FAQ.lyx, choose revert to load FAQ.lyx.emergency 4. save. Previously, a dialog will appear saying FAQ.lyx is externally modified. No such message box with the patch. Can I apply? Cheers, Bo
Index: src/Buffer.cpp =================================================================== --- src/Buffer.cpp (revision 20030) +++ src/Buffer.cpp (working copy) @@ -133,6 +133,7 @@ using support::tempName; using support::trim; using support::sum; +using support::suffixIs; namespace Alert = frontend::Alert; namespace os = support::os; @@ -696,6 +697,20 @@ int const file_format = convert<int>(tmp_format); //lyxerr << "format: " << file_format << endl; + // save timestamp and checksum of the original disk file, making sure + // to not overwrite them with those of the file created in the tempdir + // when it has to be converted to the current format. + if (!pimpl_->checksum_) { + // Save the timestamp and checksum of disk file. If filename is an + // emergency file, save the timestamp and sum of the original lyx file + // because isExternallyModified will check for this file. (BUG4193) + 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)); + } + if (file_format != LYX_FORMAT) { if (fromstring) @@ -762,9 +777,6 @@ //MacroTable::localMacros().clear(); pimpl_->file_fully_loaded = true; - // save the timestamp and checksum of disk file - pimpl_->timestamp_ = fs::last_write_time(filename.toFilesystemEncoding()); - pimpl_->checksum_ = sum(filename); return success; }