aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/synchronousprocess.h
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2016-07-05 12:00:59 +0200
committerTobias Hunger <tobias.hunger@qt.io>2016-07-15 14:16:03 +0000
commit5efd82468b0802fd0f6993b8a430acc09c6293a9 (patch)
tree5d03cd6b2d0bd32223b4b0c12015b49200c0fa13 /src/libs/utils/synchronousprocess.h
parent86882018dd39205ba281d9edcd54008e0b9d4156 (diff)
SynchronousProcess: Store raw bytes from stdout/stderr of the process
Only convert the raw output later in a stdOut() and stdErr() method of the SynchronousProcessResponse. This is necessary since we have processes that use different encodings for different sections of the file (I am looking at you, git). Also remove the signals for raw data on stdout/stderr, leaving only the signals returning buffered QString lines. This should be safe, even with UTF-16 output. Change-Id: Ida613fa86d1468cbd33bc6b3a1506a849c2d1c0a Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/libs/utils/synchronousprocess.h')
-rw-r--r--src/libs/utils/synchronousprocess.h23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/libs/utils/synchronousprocess.h b/src/libs/utils/synchronousprocess.h
index 5c4f8bc7608..a8772233644 100644
--- a/src/libs/utils/synchronousprocess.h
+++ b/src/libs/utils/synchronousprocess.h
@@ -59,12 +59,19 @@ struct QTCREATOR_UTILS_EXPORT SynchronousProcessResponse
// Helper to format an exit message.
QString exitMessage(const QString &binary, int timeoutS) const;
+
+ QByteArray allRawOutput() const;
QString allOutput() const;
+ QString stdOut() const;
+ QString stdErr() const;
+
Result result;
int exitCode;
- QString stdOut;
- QString stdErr;
+
+ QTextCodec *codec = nullptr;
+ QByteArray rawStdOut;
+ QByteArray rawStdErr;
};
QTCREATOR_UTILS_EXPORT QDebug operator<<(QDebug str, const SynchronousProcessResponse &);
@@ -132,7 +139,7 @@ public:
// occurs on stderr/stdout as opposed to waitForFinished()). Returns false if a timeout
// occurs. Checking of the process' exit state/code still has to be done.
static bool readDataFromProcess(QProcess &p, int timeoutS,
- QByteArray *stdOut = 0, QByteArray *stdErr = 0,
+ QByteArray *rawStdOut = 0, QByteArray *rawStdErr = 0,
bool timeOutMessageBox = false);
// Stop a process by first calling terminate() (allowing for signal handling) and
// then kill().
@@ -146,11 +153,8 @@ public:
static QString normalizeNewlines(const QString &text);
signals:
- void stdOut(const QString &text, bool firstTime);
- void stdErr(const QString &text, bool firstTime);
-
- void stdOutBuffered(const QString &data, bool firstTime);
- void stdErrBuffered(const QString &data, bool firstTime);
+ void stdOutBuffered(const QString &lines, bool firstTime);
+ void stdErrBuffered(const QString &lines, bool firstTime);
public slots:
bool terminate();
@@ -159,11 +163,8 @@ private:
void slotTimeout();
void finished(int exitCode, QProcess::ExitStatus e);
void error(QProcess::ProcessError);
- void stdOutReady();
- void stdErrReady();
void processStdOut(bool emitSignals);
void processStdErr(bool emitSignals);
- QString convertOutput(const QByteArray &, QTextCodec::ConverterState *state) const;
SynchronousProcessPrivate *d;
};