* AutoSaveBuffer::generateChild(): return early.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22546 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-01-14 09:04:14 +00:00
parent 2c1b8bc472
commit c81f5add99

View File

@ -2271,33 +2271,35 @@ int AutoSaveBuffer::generateChild()
pid_t const pid = fork(); pid_t const pid = fork();
// If you want to debug the autosave // If you want to debug the autosave
// you should set pid to -1, and comment out the fork. // you should set pid to -1, and comment out the fork.
if (pid == 0 || pid == -1) { if (pid != 0 && pid != -1)
// pid = -1 signifies that lyx was unable return pid;
// to fork. But we will do the save
// anyway.
bool failed = false;
FileName const tmp_ret = FileName::tempName("lyxauto"); // pid = -1 signifies that lyx was unable
if (!tmp_ret.empty()) { // to fork. But we will do the save
buffer_.writeFile(tmp_ret); // anyway.
// assume successful write of tmp_ret bool failed = false;
if (!tmp_ret.moveTo(fname_)) FileName const tmp_ret = FileName::tempName("lyxauto");
failed = true; if (!tmp_ret.empty()) {
} else buffer_.writeFile(tmp_ret);
// assume successful write of tmp_ret
if (!tmp_ret.moveTo(fname_))
failed = true; failed = true;
} else
failed = true;
if (failed) { if (failed) {
// failed to write/rename tmp_ret so try writing direct // failed to write/rename tmp_ret so try writing direct
if (!buffer_.writeFile(fname_)) { if (!buffer_.writeFile(fname_)) {
// It is dangerous to do this in the child, // It is dangerous to do this in the child,
// but safe in the parent, so... // but safe in the parent, so...
if (pid == -1) // emit message signal. if (pid == -1) // emit message signal.
buffer_.message(_("Autosave failed!")); buffer_.message(_("Autosave failed!"));
}
} }
if (pid == 0) // we are the child so...
_exit(0);
} }
if (pid == 0) // we are the child so...
_exit(0);
return pid; return pid;
} }