From 48dca70f9e0955c6d287d8130e78b3061255168b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Peter=20K=C3=BCmmel?= Date: Fri, 16 Jul 2010 05:55:31 +0000 Subject: [PATCH] only guard terminal output. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34910 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/Systemcall.cpp | 39 ++++++++++++++------------------- src/support/SystemcallPrivate.h | 10 ++------- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/src/support/Systemcall.cpp b/src/support/Systemcall.cpp index 98d8d125de..fad4f4dcc5 100644 --- a/src/support/Systemcall.cpp +++ b/src/support/Systemcall.cpp @@ -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_)); - } } } } diff --git a/src/support/SystemcallPrivate.h b/src/support/SystemcallPrivate.h index 820beac4f0..6cfb12f081 100644 --- a/src/support/SystemcallPrivate.h +++ b/src/support/SystemcallPrivate.h @@ -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_; -- 2.39.2