From e10b5a4dbbfd8705edfadf3c3b113d02460ccb33 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 4 May 2021 07:49:33 +0200 Subject: Utils: Remove SynchronousProcess::readDataFromProcess helper QtcProcess can do that nowadays. Change-Id: Ic3b08146263da2eb189f043eb743c621c18b82c8 Reviewed-by: Christian Stenger --- src/libs/utils/synchronousprocess.cpp | 44 ----------------------------------- 1 file changed, 44 deletions(-) (limited to 'src/libs/utils/synchronousprocess.cpp') 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 SynchronousProcess::createProcess(unsigned flags) return QSharedPointer(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() << "