]> git.lyx.org Git - lyx.git/blobdiff - src/support/Systemcall.cpp
InsetTabular.cpp: fix #6585 also for wrapped floats - thanks Vincent
[lyx.git] / src / support / Systemcall.cpp
index a42e7abef46be21081e2a2e28eec218e52a6c459..dda23d66bce1d83369ca2d168a30bfbfda04fbf4 100644 (file)
@@ -243,17 +243,15 @@ int Systemcall::startscript(Starttype how, string const & what, bool process_eve
 
 SystemcallPrivate::SystemcallPrivate(const std::string& of) :
                                 process_(new QProcess), 
-                                outIndex_(0),
-                                errIndex_(0),
-                                outFile_(of), 
-                                terminalOutExists_(os::is_terminal(os::STDOUT)),
-                                terminalErrExists_(os::is_terminal(os::STDERR)),
-                                processEvents_(false)
+                                out_index_(0),
+                                err_index_(0),
+                                out_file_(of), 
+                                process_events_(false)
 {
-       if (!outFile_.empty()) {
+       if (!out_file_.empty()) {
                // Check whether we have to simply throw away the output.
-               if (outFile_ != os::nulldev())
-                       process_->setStandardOutputFile(toqstr(outFile_));
+               if (out_file_ != os::nulldev())
+                       process_->setStandardOutputFile(toqstr(out_file_));
        }
 
        connect(process_, SIGNAL(readyReadStandardOutput()), SLOT(stdOut()));
@@ -277,7 +275,7 @@ void SystemcallPrivate::startProcess(const QString& cmd)
 
 void SystemcallPrivate::processEvents()
 {
-       if(processEvents_) {
+       if(process_events_) {
                QCoreApplication::processEvents(/*QEventLoop::ExcludeUserInputEvents*/);
        }
 }
@@ -295,11 +293,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 +325,16 @@ bool SystemcallPrivate::waitWhile(State waitwhile, bool process_events, int time
 
 SystemcallPrivate::~SystemcallPrivate()
 {
-       flush();
-
-       if (outIndex_) {
-               outData_[outIndex_] = '\0';
-               outIndex_ = 0;
-               if (terminalOutExists_)
-                       cout << outData_;
+       if (out_index_) {
+               out_data_[out_index_] = '\0';
+               out_index_ = 0;
+               cout << out_data_;
        }
        cout.flush();
-       if (errIndex_) {
-               errData_[errIndex_] = '\0';
-               errIndex_ = 0;
-               if (terminalErrExists_)
-                       cerr << errData_;
+       if (err_index_) {
+               err_data_[err_index_] = '\0';
+               err_index_ = 0;
+               cerr << err_data_;
        }
        cerr.flush();
 
@@ -348,39 +342,18 @@ 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 (!terminalOutExists_ && outFile_.empty())
-                       cout << fromqstr(data);
-               
-               data = QString::fromLocal8Bit(process_->readAllStandardError().data());
-               ProgressInterface::instance()->appendError(data);
-               if (!terminalErrExists_)
-                       cerr << fromqstr(data);
-       }
-}
-
-
 void SystemcallPrivate::stdOut()
 {
        if (process_) {
                char c;
                process_->setReadChannel(QProcess::StandardOutput);
                while (process_->getChar(&c)) {
-                       outData_[outIndex_++] = c;
-                       if (c == '\n' || outIndex_ + 1 == bufferSize_) {
-                               outData_[outIndex_] = '\0';
-                               outIndex_ = 0;
-                               ProgressInterface::instance()->appendMessage(QString::fromLocal8Bit(outData_));
-                               if (terminalOutExists_)
-                                       cout << outData_;
+                       out_data_[out_index_++] = c;
+                       if (c == '\n' || out_index_ + 1 == buffer_size_) {
+                               out_data_[out_index_] = '\0';
+                               out_index_ = 0;
+                               ProgressInterface::instance()->appendMessage(QString::fromLocal8Bit(out_data_));
+                               cout << out_data_;
                        }
                }
        }
@@ -393,13 +366,12 @@ void SystemcallPrivate::stdErr()
                char c;
                process_->setReadChannel(QProcess::StandardError);
                while (process_->getChar(&c)) {
-                       errData_[errIndex_++] = c;
-                       if (c == '\n' || errIndex_ + 1 == bufferSize_) {
-                               errData_[errIndex_] = '\0';
-                               errIndex_ = 0;
-                               ProgressInterface::instance()->appendError(QString::fromLocal8Bit(errData_));
-                               if (terminalErrExists_)
-                                       cerr << errData_;
+                       err_data_[err_index_++] = c;
+                       if (c == '\n' || err_index_ + 1 == buffer_size_) {
+                               err_data_[err_index_] = '\0';
+                               err_index_ = 0;
+                               ProgressInterface::instance()->appendError(QString::fromLocal8Bit(err_data_));
+                               cerr << err_data_;
                        }
                }
        }