]> git.lyx.org Git - features.git/commitdiff
only guard terminal output.
authorPeter Kümmel <syntheticpp@gmx.net>
Fri, 16 Jul 2010 05:55:31 +0000 (05:55 +0000)
committerPeter Kümmel <syntheticpp@gmx.net>
Fri, 16 Jul 2010 05:55:31 +0000 (05:55 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34910 a592a061-630c-0410-9148-cb99ea01b6c8

src/support/Systemcall.cpp
src/support/SystemcallPrivate.h

index 98d8d125dea618b29523f795670bb042f8b410d3..fad4f4dcc59463f9db7dc9399d7d8fedf21448bd 100644 (file)
@@ -241,18 +241,18 @@ int Systemcall::startscript(Starttype how, string const & what, bool process_eve
 }
 
 
-SystemcallPrivate::SystemcallPrivate(const std::string& of) : 
+SystemcallPrivate::SystemcallPrivate(const std::string& of) :
                                 proc_(new QProcess), outindex_(0), errindex_(0),
-                                outfile(of), showout_(false), showerr_(false), process_events(false)
+                                outfile(of), 
+                                terminalOutExists_(os::is_terminal(os::STDOUT)),
+                                terminalErrExists_(os::is_terminal(os::STDERR)),
+                                process_events(false)
 {
        if (!outfile.empty()) {
                // Check whether we have to simply throw away the output.
                if (outfile != os::nulldev())
                        proc_->setStandardOutputFile(toqstr(outfile));
-       } else if (os::is_terminal(os::STDOUT))
-               setShowOut(true);
-       if (os::is_terminal(os::STDERR))
-               setShowErr(true);
+       }
 
        connect(proc_, SIGNAL(readyReadStandardOutput()), SLOT(stdOut()));
        connect(proc_, SIGNAL(readyReadStandardError()), SLOT(stdErr()));
@@ -330,14 +330,14 @@ SystemcallPrivate::~SystemcallPrivate()
        if (outindex_) {
                outdata_[outindex_] = '\0';
                outindex_ = 0;
-               if (showout_)
+               if (terminalOutExists_)
                        cout << outdata_;
        }
        cout.flush();
        if (errindex_) {
                errdata_[errindex_] = '\0';
                errindex_ = 0;
-               if (showerr_)
+               if (terminalErrExists_)
                        cerr << errdata_;
        }
        cerr.flush();
@@ -354,17 +354,14 @@ void SystemcallPrivate::flush()
                // to some log file, for example ~/.xsession-errors on *nix.
                
                QString data = QString::fromLocal8Bit(proc_->readAllStandardOutput().data());
-               if (showout_) 
-                       ProgressInterface::instance()->appendMessage(data);
-               if (!os::is_terminal(os::STDOUT) && outfile.empty()) 
+               ProgressInterface::instance()->appendMessage(data);
+               if (!terminalOutExists_ && outfile.empty())
                        cout << fromqstr(data);
                
                data = QString::fromLocal8Bit(proc_->readAllStandardError().data());
-               if (showerr_) 
-                       ProgressInterface::instance()->appendError(data);
-               if (!os::is_terminal(os::STDERR)) 
-                       cerr << fromqstr(data);                 
-               
+               ProgressInterface::instance()->appendError(data);
+               if (!terminalErrExists_)
+                       cerr << fromqstr(data);
        }
 }
 
@@ -379,10 +376,9 @@ void SystemcallPrivate::stdOut()
                        if (c == '\n' || outindex_ + 1 == bufsize_) {
                                outdata_[outindex_] = '\0';
                                outindex_ = 0;
-                               if (showout_) {
+                               ProgressInterface::instance()->appendMessage(QString::fromLocal8Bit(outdata_));
+                               if (terminalOutExists_)
                                        cout << outdata_;
-                                       ProgressInterface::instance()->appendMessage(QString::fromLocal8Bit(outdata_));         
-                               }
                        }
                }
        }
@@ -399,10 +395,9 @@ void SystemcallPrivate::stdErr()
                        if (c == '\n' || errindex_ + 1 == bufsize_) {
                                errdata_[errindex_] = '\0';
                                errindex_ = 0;
-                               if (showerr_) {
+                               ProgressInterface::instance()->appendError(QString::fromLocal8Bit(errdata_));
+                               if (terminalErrExists_)
                                        cerr << errdata_;
-                                       ProgressInterface::instance()->appendError(QString::fromLocal8Bit(errdata_));
-                               }
                        }
                }
        }
index 820beac4f0f2d196d59981f0d83a56390032212b..6cfb12f081ca0e5188481bfc97f9d976ea66dc8f 100644 (file)
@@ -34,12 +34,6 @@ public:
        SystemcallPrivate(std::string const & outfile);
        ~SystemcallPrivate();
 
-       /// Should the standard output be displayed?
-       void setShowOut(bool val) { showout_ = val; }
-
-       /// Should the standard error be displayed?
-       void setShowErr(bool val) { showerr_ = val; }
-
        enum State {
                Starting,
                Running,
@@ -78,9 +72,9 @@ private:
        /// Standard error buffer.
        char errdata_[bufsize_];
        /// 
-       bool showout_;
+       bool terminalErrExists_;
        /// 
-       bool showerr_;
+       bool terminalOutExists_;
        bool process_events;
        QString cmd_;