mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 02:14:50 +00:00
only guard terminal output.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34910 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a24a1e3bfe
commit
48dca70f9e
@ -243,16 +243,16 @@ 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),
|
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()) {
|
if (!outfile.empty()) {
|
||||||
// Check whether we have to simply throw away the output.
|
// Check whether we have to simply throw away the output.
|
||||||
if (outfile != os::nulldev())
|
if (outfile != os::nulldev())
|
||||||
proc_->setStandardOutputFile(toqstr(outfile));
|
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(readyReadStandardOutput()), SLOT(stdOut()));
|
||||||
connect(proc_, SIGNAL(readyReadStandardError()), SLOT(stdErr()));
|
connect(proc_, SIGNAL(readyReadStandardError()), SLOT(stdErr()));
|
||||||
@ -330,14 +330,14 @@ SystemcallPrivate::~SystemcallPrivate()
|
|||||||
if (outindex_) {
|
if (outindex_) {
|
||||||
outdata_[outindex_] = '\0';
|
outdata_[outindex_] = '\0';
|
||||||
outindex_ = 0;
|
outindex_ = 0;
|
||||||
if (showout_)
|
if (terminalOutExists_)
|
||||||
cout << outdata_;
|
cout << outdata_;
|
||||||
}
|
}
|
||||||
cout.flush();
|
cout.flush();
|
||||||
if (errindex_) {
|
if (errindex_) {
|
||||||
errdata_[errindex_] = '\0';
|
errdata_[errindex_] = '\0';
|
||||||
errindex_ = 0;
|
errindex_ = 0;
|
||||||
if (showerr_)
|
if (terminalErrExists_)
|
||||||
cerr << errdata_;
|
cerr << errdata_;
|
||||||
}
|
}
|
||||||
cerr.flush();
|
cerr.flush();
|
||||||
@ -354,17 +354,14 @@ void SystemcallPrivate::flush()
|
|||||||
// to some log file, for example ~/.xsession-errors on *nix.
|
// to some log file, for example ~/.xsession-errors on *nix.
|
||||||
|
|
||||||
QString data = QString::fromLocal8Bit(proc_->readAllStandardOutput().data());
|
QString data = QString::fromLocal8Bit(proc_->readAllStandardOutput().data());
|
||||||
if (showout_)
|
ProgressInterface::instance()->appendMessage(data);
|
||||||
ProgressInterface::instance()->appendMessage(data);
|
if (!terminalOutExists_ && outfile.empty())
|
||||||
if (!os::is_terminal(os::STDOUT) && outfile.empty())
|
|
||||||
cout << fromqstr(data);
|
cout << fromqstr(data);
|
||||||
|
|
||||||
data = QString::fromLocal8Bit(proc_->readAllStandardError().data());
|
data = QString::fromLocal8Bit(proc_->readAllStandardError().data());
|
||||||
if (showerr_)
|
ProgressInterface::instance()->appendError(data);
|
||||||
ProgressInterface::instance()->appendError(data);
|
if (!terminalErrExists_)
|
||||||
if (!os::is_terminal(os::STDERR))
|
|
||||||
cerr << fromqstr(data);
|
cerr << fromqstr(data);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,10 +376,9 @@ void SystemcallPrivate::stdOut()
|
|||||||
if (c == '\n' || outindex_ + 1 == bufsize_) {
|
if (c == '\n' || outindex_ + 1 == bufsize_) {
|
||||||
outdata_[outindex_] = '\0';
|
outdata_[outindex_] = '\0';
|
||||||
outindex_ = 0;
|
outindex_ = 0;
|
||||||
if (showout_) {
|
ProgressInterface::instance()->appendMessage(QString::fromLocal8Bit(outdata_));
|
||||||
|
if (terminalOutExists_)
|
||||||
cout << outdata_;
|
cout << outdata_;
|
||||||
ProgressInterface::instance()->appendMessage(QString::fromLocal8Bit(outdata_));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -399,10 +395,9 @@ void SystemcallPrivate::stdErr()
|
|||||||
if (c == '\n' || errindex_ + 1 == bufsize_) {
|
if (c == '\n' || errindex_ + 1 == bufsize_) {
|
||||||
errdata_[errindex_] = '\0';
|
errdata_[errindex_] = '\0';
|
||||||
errindex_ = 0;
|
errindex_ = 0;
|
||||||
if (showerr_) {
|
ProgressInterface::instance()->appendError(QString::fromLocal8Bit(errdata_));
|
||||||
|
if (terminalErrExists_)
|
||||||
cerr << errdata_;
|
cerr << errdata_;
|
||||||
ProgressInterface::instance()->appendError(QString::fromLocal8Bit(errdata_));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,6 @@ public:
|
|||||||
SystemcallPrivate(std::string const & outfile);
|
SystemcallPrivate(std::string const & outfile);
|
||||||
~SystemcallPrivate();
|
~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 {
|
enum State {
|
||||||
Starting,
|
Starting,
|
||||||
Running,
|
Running,
|
||||||
@ -78,9 +72,9 @@ private:
|
|||||||
/// Standard error buffer.
|
/// Standard error buffer.
|
||||||
char errdata_[bufsize_];
|
char errdata_[bufsize_];
|
||||||
///
|
///
|
||||||
bool showout_;
|
bool terminalErrExists_;
|
||||||
///
|
///
|
||||||
bool showerr_;
|
bool terminalOutExists_;
|
||||||
bool process_events;
|
bool process_events;
|
||||||
QString cmd_;
|
QString cmd_;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user