summaryrefslogtreecommitdiff
path: root/src/libs/utils/synchronousprocess.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2021-05-04 07:49:33 +0200
committerhjk <hjk@qt.io>2021-05-07 12:42:18 +0000
commite10b5a4dbbfd8705edfadf3c3b113d02460ccb33 (patch)
tree35989fb835ce035a22a5b6f27d023e49e038b75a /src/libs/utils/synchronousprocess.cpp
parent9c3420120ea9b477a8677de667e0b3dc5375159b (diff)
downloadqt-creator-e10b5a4dbbfd8705edfadf3c3b113d02460ccb33.tar.gz
Utils: Remove SynchronousProcess::readDataFromProcess helper
QtcProcess can do that nowadays. Change-Id: Ic3b08146263da2eb189f043eb743c621c18b82c8 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/libs/utils/synchronousprocess.cpp')
-rw-r--r--src/libs/utils/synchronousprocess.cpp44
1 files changed, 0 insertions, 44 deletions
diff --git a/src/libs/utils/synchronousprocess.cpp b/src/libs/utils/synchronousprocess.cpp
index a52fbd8f7e..cb2e1a5832 100644
--- a/src/libs/utils/synchronousprocess.cpp
+++ b/src/libs/utils/synchronousprocess.cpp
@@ -645,50 +645,6 @@ QSharedPointer<QProcess> SynchronousProcess::createProcess(unsigned flags)
return QSharedPointer<QProcess>(process);
}
-// Static utilities: Keep running as long as it gets data.
-bool SynchronousProcess::readDataFromProcess(QProcess &p, int timeoutS,
- QByteArray *stdOut, QByteArray *stdErr,
- bool showTimeOutMessageBox)
-{
- if (syncDebug)
- qDebug() << ">readDataFromProcess" << timeoutS;
- if (p.state() != QProcess::Running) {
- qWarning("readDataFromProcess: Process in non-running state passed in.");
- return false;
- }
-
- QTC_ASSERT(p.readChannel() == QProcess::StandardOutput, return false);
-
- // Keep the process running until it has no longer has data
- bool finished = false;
- bool hasData = false;
- do {
- finished = p.waitForFinished(timeoutS > 0 ? timeoutS * 1000 : -1)
- || p.state() == QProcess::NotRunning;
- // First check 'stdout'
- if (p.bytesAvailable()) { // applies to readChannel() only
- hasData = true;
- const QByteArray newStdOut = p.readAllStandardOutput();
- if (stdOut)
- stdOut->append(newStdOut);
- }
- // Check 'stderr' separately. This is a special handling
- // for 'git pull' and the like which prints its progress on stderr.
- const QByteArray newStdErr = p.readAllStandardError();
- if (!newStdErr.isEmpty()) {
- hasData = true;
- if (stdErr)
- stdErr->append(newStdErr);
- }
- // Prompt user, pretend we have data if says 'No'.
- const bool hang = !hasData && !finished;
- hasData = hang && showTimeOutMessageBox && !askToKill(p.program());
- } while (hasData && !finished);
- if (syncDebug)
- qDebug() << "<readDataFromProcess" << finished;
- return finished;
-}
-
// Path utilities
// Locate a binary in a directory, applying all kinds of