Prevent boost::filesystem assert (w/ dataloss) when the backup dir was invalid or not writeable. War the user instead and skip backup (bug 2740)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_4_X@14576 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2006-08-08 14:39:08 +00:00
parent 08b31ac8a5
commit 365a2daf53
3 changed files with 18 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2006-08-08 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* buffer.C (save): Check if the backup directory is valid and
writeable, and warn the user if not (instead of letting boost
assert) [bug 2740].
2006-08-08 Georg Baum <Georg.Baum@post.rwth-aachen.de> 2006-08-08 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* LaTeX.C (deplog): Add the toc file to the dependencies if a line * LaTeX.C (deplog): Add the toc file to the dependencies if a line

View File

@ -701,7 +701,10 @@ bool Buffer::save() const
// good enough. (Lgb) // good enough. (Lgb)
// But to use this we need fs::copy_file to actually do a copy, // But to use this we need fs::copy_file to actually do a copy,
// even when the target file exists. (Lgb) // even when the target file exists. (Lgb)
if (fs::exists(fileName()) && fs::is_writable(fs::path(fileName()).branch_path())) { if (fs::exists(fileName())
&& fs::is_writable(fs::path(fileName()).branch_path())
&& fs::exists(fs::path(s).branch_path())
&& fs::is_writable(fs::path(s).branch_path())) {
//try { //try {
fs::copy_file(fileName(), s, false); fs::copy_file(fileName(), s, false);
//} //}
@ -709,6 +712,11 @@ bool Buffer::save() const
//lyxerr << "LyX was not able to make backup copy. Beware.\n" //lyxerr << "LyX was not able to make backup copy. Beware.\n"
// << fe.what() << endl; // << fe.what() << endl;
//} //}
} else {
Alert::error(_("Backup failure"),
bformat(_("LyX was not able to make a backup copy in %1$s.\n"
"Please check if the directory exists and is writeable."),
fs::path(s).branch_path().native_directory_string()));
} }
} }

View File

@ -26,6 +26,9 @@ What's new
* Document Input/Output * Document Input/Output
- Fix crash on save (including dataloss) when the backup directory
was invalid or not writeable(bug 2740).
- Fix crash when importing LaTeX files with no text (bug 2667) - Fix crash when importing LaTeX files with no text (bug 2667)
- Ignore definition of lyxgreyout environment when re-importing a LyX - Ignore definition of lyxgreyout environment when re-importing a LyX