]> git.lyx.org Git - lyx.git/blobdiff - src/support/Systemcall.cpp
Fix samba related crashes
[lyx.git] / src / support / Systemcall.cpp
index a328e367e19898ee65a0ee0163ba8556919ffb10..5713294055d9a9fe0a56977e12c8c98137ac7c3f 100644 (file)
@@ -225,8 +225,9 @@ int Systemcall::startscript(Starttype how, string const & what, bool process_eve
                return 0;
        }
 
-       if (!d.waitWhile(SystemcallPrivate::Running, process_events, 180000)) {
-               LYXERR0("Systemcall: '" << cmd << "' did not finished!");
+       int timeout_min = 30;
+       if (!d.waitWhile(SystemcallPrivate::Running, process_events, timeout_min * 60 * 1000)) {
+               LYXERR0("Systemcall: '" << cmd << "' did not finish!");
                LYXERR0("error " << d.errorMessage());
                LYXERR0("status " << d.exitStatusMessage());
                return 20;
@@ -246,8 +247,6 @@ SystemcallPrivate::SystemcallPrivate(const std::string& of) :
                                 out_index_(0),
                                 err_index_(0),
                                 out_file_(of), 
-                                terminal_out_exists_(os::is_terminal(os::STDOUT)),
-                                terminal_err_exists_(os::is_terminal(os::STDERR)),
                                 process_events_(false)
 {
        if (!out_file_.empty()) {
@@ -295,11 +294,11 @@ bool SystemcallPrivate::waitWhile(State waitwhile, bool process_events, int time
        if (!process_)
                return false;
 
-       process_events = process_events;
+       process_events_ = process_events;
 
        // Block GUI while waiting,
        // relay on QProcess' wait functions
-       if (!process_events) {
+       if (!process_events_) {
                if (waitwhile == Starting)
                        return process_->waitForStarted(timeout);
                if (waitwhile == Running)
@@ -327,20 +326,16 @@ bool SystemcallPrivate::waitWhile(State waitwhile, bool process_events, int time
 
 SystemcallPrivate::~SystemcallPrivate()
 {
-       flush();
-
        if (out_index_) {
                out_data_[out_index_] = '\0';
                out_index_ = 0;
-               if (terminal_out_exists_)
-                       cout << out_data_;
+               cout << out_data_;
        }
        cout.flush();
        if (err_index_) {
                err_data_[err_index_] = '\0';
                err_index_ = 0;
-               if (terminal_err_exists_)
-                       cerr << err_data_;
+               cerr << err_data_;
        }
        cerr.flush();
 
@@ -348,26 +343,6 @@ SystemcallPrivate::~SystemcallPrivate()
 }
 
 
-void SystemcallPrivate::flush()
-{
-       if (process_) {
-               // If the output has been redirected, we write it all at once.
-               // Even if we are not running in a terminal, the output could go
-               // to some log file, for example ~/.xsession-errors on *nix.
-               
-               QString data = QString::fromLocal8Bit(process_->readAllStandardOutput().data());
-               ProgressInterface::instance()->appendMessage(data);
-               if (!terminal_out_exists_ && out_file_.empty())
-                       cout << fromqstr(data);
-               
-               data = QString::fromLocal8Bit(process_->readAllStandardError().data());
-               ProgressInterface::instance()->appendError(data);
-               if (!terminal_err_exists_)
-                       cerr << fromqstr(data);
-       }
-}
-
-
 void SystemcallPrivate::stdOut()
 {
        if (process_) {
@@ -375,12 +350,11 @@ void SystemcallPrivate::stdOut()
                process_->setReadChannel(QProcess::StandardOutput);
                while (process_->getChar(&c)) {
                        out_data_[out_index_++] = c;
-                       if (c == '\n' || out_index_ + 1 == max_buffer_size_) {
+                       if (c == '\n' || out_index_ + 1 == buffer_size_) {
                                out_data_[out_index_] = '\0';
                                out_index_ = 0;
                                ProgressInterface::instance()->appendMessage(QString::fromLocal8Bit(out_data_));
-                               if (terminal_out_exists_)
-                                       cout << out_data_;
+                               cout << out_data_;
                        }
                }
        }
@@ -394,12 +368,11 @@ void SystemcallPrivate::stdErr()
                process_->setReadChannel(QProcess::StandardError);
                while (process_->getChar(&c)) {
                        err_data_[err_index_++] = c;
-                       if (c == '\n' || err_index_ + 1 == max_buffer_size_) {
+                       if (c == '\n' || err_index_ + 1 == buffer_size_) {
                                err_data_[err_index_] = '\0';
                                err_index_ = 0;
                                ProgressInterface::instance()->appendError(QString::fromLocal8Bit(err_data_));
-                               if (terminal_err_exists_)
-                                       cerr << err_data_;
+                               cerr << err_data_;
                        }
                }
        }