Remove code that has not been used since 2010.

See 208acbc72.
This commit is contained in:
Richard Kimberly Heck 2020-02-28 00:21:48 -05:00
parent b750941910
commit 0dc9fca86e

View File

@ -4235,91 +4235,6 @@ void Buffer::setGuiDelegate(frontend::GuiBufferDelegate * gui)
}
namespace {
class AutoSaveBuffer : public ForkedProcess {
public:
///
AutoSaveBuffer(Buffer const & buffer, FileName const & fname)
: buffer_(buffer), fname_(fname) {}
///
virtual shared_ptr<ForkedProcess> clone() const
{
return make_shared<AutoSaveBuffer>(*this);
}
///
int start()
{
command_ = to_utf8(bformat(_("Auto-saving %1$s"),
from_utf8(fname_.absFileName())));
return run(DontWait);
}
private:
///
virtual int generateChild();
///
Buffer const & buffer_;
FileName fname_;
};
int AutoSaveBuffer::generateChild()
{
#if defined(__APPLE__)
/* FIXME fork() is not usable for autosave on Mac OS X 10.6 (snow leopard)
* We should use something else like threads.
*
* Since I do not know how to determine at run time what is the OS X
* version, I just disable forking altogether for now (JMarc)
*/
pid_t const pid = -1;
#else
// tmp_ret will be located (usually) in /tmp
// will that be a problem?
// Note that this calls ForkedCalls::fork(), so it's
// ok cross-platform.
pid_t const pid = fork();
// If you want to debug the autosave
// you should set pid to -1, and comment out the fork.
if (pid != 0 && pid != -1)
return pid;
#endif
// pid = -1 signifies that lyx was unable
// to fork. But we will do the save
// anyway.
bool failed = false;
TempFile tempfile("lyxautoXXXXXX.lyx");
tempfile.setAutoRemove(false);
FileName const tmp_ret = tempfile.name();
if (!tmp_ret.empty()) {
if (!buffer_.writeFile(tmp_ret))
failed = true;
else if (!tmp_ret.moveTo(fname_))
failed = true;
} else
failed = true;
if (failed) {
// failed to write/rename tmp_ret so try writing direct
if (!buffer_.writeFile(fname_)) {
// It is dangerous to do this in the child,
// but safe in the parent, so...
if (pid == -1) // emit message signal.
buffer_.message(_("Autosave failed!"));
}
}
if (pid == 0) // we are the child so...
_exit(0);
return pid;
}
} // namespace
FileName Buffer::getEmergencyFileName() const
{
return FileName(d->filename.absFileName() + ".emergency");