forked from qt-creator/qt-creator
Process: Use more rawStd{Out,Err} const methods instead of mutable ones
Avoid using readAllStandard{Output,Error} mutable methods if possible. Use non-mutable methods when we are not connected to readyReadStandard{Output,Error} signals. Change-Id: I2e830e571b9eab2177fd856bbe06dfc5137d9c01 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -1035,7 +1035,7 @@ expected_str<QByteArray> UnixDeviceFileAccess::fileContents(const FilePath &file
|
||||
return make_unexpected(Tr::tr("Failed reading file \"%1\": %2")
|
||||
.arg(filePath.toUserOutput(), p.readAllStandardError()));
|
||||
}
|
||||
return p.readAllRawStandardOutput();
|
||||
return p.rawStdOut();
|
||||
#else
|
||||
return make_unexpected(QString("Not implemented"));
|
||||
#endif
|
||||
|
@@ -90,8 +90,8 @@ RunResult DeviceShell::run(const CommandLine &cmd, const QByteArray &stdInData)
|
||||
|
||||
return RunResult{
|
||||
proc.exitCode(),
|
||||
proc.readAllRawStandardOutput(),
|
||||
proc.readAllRawStandardError()
|
||||
proc.rawStdOut(),
|
||||
proc.rawStdErr()
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -253,7 +253,7 @@ bool AndroidAvdManager::startAvdAsync(const QString &avdName) const
|
||||
avdProcess->setProcessChannelMode(QProcess::MergedChannels);
|
||||
QObject::connect(avdProcess, &Process::done, avdProcess, [avdProcess] {
|
||||
if (avdProcess->exitCode()) {
|
||||
const QString errorOutput = QString::fromLatin1(avdProcess->readAllRawStandardOutput());
|
||||
const QString errorOutput = QString::fromLatin1(avdProcess->rawStdOut());
|
||||
QMetaObject::invokeMethod(Core::ICore::mainWindow(), [errorOutput] {
|
||||
const QString title = Tr::tr("AVD Start Error");
|
||||
QMessageBox::critical(Core::ICore::dialogParent(), title, errorOutput);
|
||||
|
@@ -1525,7 +1525,7 @@ FilePath AndroidConfig::getJdkPath()
|
||||
findJdkPathProc.setCommand({"sh", args});
|
||||
findJdkPathProc.start();
|
||||
findJdkPathProc.waitForFinished();
|
||||
QByteArray jdkPath = findJdkPathProc.readAllRawStandardOutput().trimmed();
|
||||
QByteArray jdkPath = findJdkPathProc.rawStdOut().trimmed();
|
||||
|
||||
if (HostOsInfo::isMacHost()) {
|
||||
jdkHome = FilePath::fromUtf8(jdkPath);
|
||||
|
@@ -79,9 +79,9 @@ AxivionQueryRunner::AxivionQueryRunner(const AxivionQuery &query, QObject *paren
|
||||
start();
|
||||
return;
|
||||
}
|
||||
emit resultRetrieved(m_process.readAllRawStandardError());
|
||||
emit resultRetrieved(m_process.rawStdErr());
|
||||
} else {
|
||||
emit resultRetrieved(m_process.readAllRawStandardOutput());
|
||||
emit resultRetrieved(m_process.rawStdOut());
|
||||
}
|
||||
emit finished();
|
||||
});
|
||||
|
@@ -1892,8 +1892,7 @@ void CMakeBuildSystem::runCTest()
|
||||
m_ctestProcess->setCommand({m_ctestPath, { "-N", "--show-only=json-v1"}});
|
||||
connect(m_ctestProcess.get(), &Process::done, this, [this] {
|
||||
if (m_ctestProcess->result() == ProcessResult::FinishedWithSuccess) {
|
||||
const QJsonDocument json
|
||||
= QJsonDocument::fromJson(m_ctestProcess->readAllRawStandardOutput());
|
||||
const QJsonDocument json = QJsonDocument::fromJson(m_ctestProcess->rawStdOut());
|
||||
if (!json.isEmpty() && json.isObject()) {
|
||||
const QJsonObject jsonObj = json.object();
|
||||
const QJsonObject btGraph = jsonObj.value("backtraceGraph").toObject();
|
||||
|
@@ -20,7 +20,7 @@ CppcheckRunner::CppcheckRunner(CppcheckTool &tool) : m_tool(tool)
|
||||
getConf.setCommand({"getconf", {"ARG_MAX"}});
|
||||
getConf.start();
|
||||
getConf.waitForFinished(2000);
|
||||
const QByteArray argMax = getConf.readAllRawStandardOutput().replace("\n", "");
|
||||
const QByteArray argMax = getConf.rawStdOut().replace("\n", "");
|
||||
m_maxArgumentsLength = std::max(argMax.toInt(), m_maxArgumentsLength);
|
||||
}
|
||||
|
||||
|
@@ -363,7 +363,7 @@ static FilePath getClangHeadersPathFromClang(const FilePath &clangdFilePath)
|
||||
if (!clang.waitForFinished())
|
||||
return {};
|
||||
const FilePath resourceDir = FilePath::fromUserInput(QString::fromLocal8Bit(
|
||||
clang.readAllRawStandardOutput().trimmed()));
|
||||
clang.rawStdOut().trimmed()));
|
||||
if (resourceDir.isEmpty() || !resourceDir.exists())
|
||||
return {};
|
||||
const FilePath includeDir = resourceDir.pathAppended("include");
|
||||
|
@@ -475,7 +475,7 @@ void CppModelManager::showPreprocessedFile(bool inNextSplit)
|
||||
return;
|
||||
}
|
||||
if (isMsvc)
|
||||
saveAndOpen(outFilePath, compiler->readAllRawStandardOutput(), inNextSplit);
|
||||
saveAndOpen(outFilePath, compiler->rawStdOut(), inNextSplit);
|
||||
else
|
||||
openEditor(outFilePath, inNextSplit, Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
|
||||
});
|
||||
|
@@ -110,7 +110,7 @@ QueryRunner::QueryRunner(const Query &query, const Id &id, QObject *parent)
|
||||
}
|
||||
VcsBase::VcsOutputWindow::appendError(m_process.exitMessage());
|
||||
} else {
|
||||
emit resultRetrieved(m_process.readAllRawStandardOutput());
|
||||
emit resultRetrieved(m_process.rawStdOut());
|
||||
}
|
||||
emit finished();
|
||||
});
|
||||
|
@@ -42,7 +42,7 @@ inline bool run_meson(const Command &command, QIODevice *output = nullptr)
|
||||
if (!process.waitForFinished())
|
||||
return false;
|
||||
if (output) {
|
||||
output->write(process.readAllRawStandardOutput());
|
||||
output->write(process.rawStdOut());
|
||||
}
|
||||
return process.exitCode() == 0;
|
||||
}
|
||||
|
@@ -165,9 +165,8 @@ void PerfConfigWidget::handleProcessDone()
|
||||
useTracePointsButton->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
const QList<QByteArray> lines =
|
||||
m_process->readAllRawStandardOutput().append(m_process->readAllRawStandardError())
|
||||
.split('\n');
|
||||
const QList<QByteArray> lines
|
||||
= m_process->rawStdOut().append(m_process->rawStdErr()).split('\n');
|
||||
auto model = eventsView->model();
|
||||
const int previousRows = model->rowCount();
|
||||
QHash<QByteArray, QByteArray> tracePoints;
|
||||
|
@@ -88,7 +88,7 @@ void DeviceUsedPortsGatherer::setupUsedPorts()
|
||||
{
|
||||
d->usedPorts.clear();
|
||||
const QList<Port> usedPorts = d->portsGatheringMethod.parsePorts(
|
||||
d->process->readAllRawStandardOutput());
|
||||
d->process->rawStdOut());
|
||||
for (const Port port : usedPorts) {
|
||||
if (d->device->freePorts().contains(port))
|
||||
d->usedPorts << port;
|
||||
|
@@ -235,9 +235,9 @@ QString QbsProfileManager::runQbsConfig(QbsConfigOp op, const QString &key, cons
|
||||
} else if (qbsConfig.exitCode() != 0) {
|
||||
Core::MessageManager::writeFlashing(
|
||||
Tr::tr("Failed to run qbs config: %1")
|
||||
.arg(QString::fromLocal8Bit(qbsConfig.readAllRawStandardError())));
|
||||
.arg(QString::fromLocal8Bit(qbsConfig.rawStdErr())));
|
||||
}
|
||||
return QString::fromLocal8Bit(qbsConfig.readAllRawStandardOutput()).trimmed();
|
||||
return QString::fromLocal8Bit(qbsConfig.rawStdOut()).trimmed();
|
||||
}
|
||||
|
||||
QVariant fromJSLiteral(const QString &str)
|
||||
|
@@ -37,7 +37,7 @@ static QString getQbsVersion(const FilePath &qbsExe)
|
||||
qbsProc.start();
|
||||
if (!qbsProc.waitForFinished(5000) || qbsProc.exitCode() != 0)
|
||||
return {};
|
||||
return QString::fromLocal8Bit(qbsProc.readAllRawStandardOutput()).trimmed();
|
||||
return QString::fromLocal8Bit(qbsProc.rawStdOut()).trimmed();
|
||||
}
|
||||
|
||||
static bool operator==(const QbsSettingsData &s1, const QbsSettingsData &s2)
|
||||
|
@@ -1817,7 +1817,7 @@ static QByteArray runQmakeQuery(const FilePath &binary, const Environment &env,
|
||||
return {};
|
||||
}
|
||||
|
||||
const QByteArray out = process.readAllRawStandardOutput();
|
||||
const QByteArray out = process.rawStdOut();
|
||||
if (out.isEmpty()) {
|
||||
*error = Tr::tr("\"%1\" produced no output: %2.")
|
||||
.arg(binary.displayName(), process.cleanedStdErr());
|
||||
|
@@ -59,8 +59,8 @@ static void processRunnerCallback(ProcessData *data)
|
||||
|
||||
data->exitCode = proc.exitCode();
|
||||
data->exitStatus = proc.exitStatus();
|
||||
data->stdErr = proc.readAllRawStandardError();
|
||||
data->stdOut = proc.readAllRawStandardOutput();
|
||||
data->stdErr = proc.rawStdErr();
|
||||
data->stdOut = proc.rawStdOut();
|
||||
}
|
||||
|
||||
class QtSupportPlugin final : public ExtensionSystem::IPlugin
|
||||
|
@@ -410,7 +410,7 @@ QList<QByteArray> QtVersionManagerImpl::runQtChooser(const QString &qtchooser, c
|
||||
p.start();
|
||||
p.waitForFinished();
|
||||
const bool success = p.exitCode() == 0;
|
||||
return success ? p.readAllRawStandardOutput().split('\n') : QList<QByteArray>();
|
||||
return success ? p.rawStdOut().split('\n') : QList<QByteArray>();
|
||||
}
|
||||
|
||||
// Asks qtchooser for the qmake path of a given version
|
||||
|
@@ -88,8 +88,7 @@ void RemoteLinuxSignalOperation::runnerDone()
|
||||
m_errorMessage = m_process->errorString();
|
||||
} else if (m_process->exitCode() != 0) {
|
||||
m_errorMessage = Tr::tr("Exit code is %1. stderr:").arg(m_process->exitCode())
|
||||
+ QLatin1Char(' ')
|
||||
+ QString::fromLatin1(m_process->readAllRawStandardError());
|
||||
+ QLatin1Char(' ') + QString::fromLatin1(m_process->rawStdErr());
|
||||
}
|
||||
m_process.release()->deleteLater();
|
||||
emit finished(m_errorMessage);
|
||||
|
@@ -118,7 +118,7 @@ void SshKeyCreationDialog::generateKeys()
|
||||
if (!keygen.waitForFinished())
|
||||
errorMsg = keygen.errorString();
|
||||
else if (keygen.exitCode() != 0)
|
||||
errorMsg = QString::fromLocal8Bit(keygen.readAllRawStandardError());
|
||||
errorMsg = QString::fromLocal8Bit(keygen.rawStdErr());
|
||||
if (!errorMsg.isEmpty()) {
|
||||
showError(Tr::tr("The ssh-keygen tool at \"%1\" failed: %2")
|
||||
.arg(SshSettings::keygenFilePath().toUserOutput(), errorMsg));
|
||||
|
@@ -662,8 +662,7 @@ CropAndTrimDialog::CropAndTrimDialog(const ClipInfo &clip, QWidget *parent)
|
||||
m_process = new Process(this);
|
||||
connect(m_process, &Process::done, this, [this] {
|
||||
if (m_process->exitCode() != 0) {
|
||||
FFmpegUtils::reportError(m_process->commandLine(),
|
||||
m_process->readAllRawStandardError());
|
||||
FFmpegUtils::reportError(m_process->commandLine(), m_process->rawStdErr());
|
||||
return;
|
||||
}
|
||||
const QByteArray &imageData = m_process->rawStdOut();
|
||||
|
@@ -129,7 +129,7 @@ public:
|
||||
reportFailure();
|
||||
return;
|
||||
}
|
||||
const QByteArrayList data = m_process->readAllRawStandardOutput().split(' ');
|
||||
const QByteArrayList data = m_process->rawStdOut().split(' ');
|
||||
if (data.size() != 3) {
|
||||
reportFailure();
|
||||
return;
|
||||
|
@@ -103,7 +103,7 @@ static WebBrowserEntries emrunBrowsers(Target *target)
|
||||
browserLister.start();
|
||||
|
||||
if (browserLister.waitForFinished())
|
||||
result.append(parseEmrunOutput(browserLister.readAllRawStandardOutput()));
|
||||
result.append(parseEmrunOutput(browserLister.rawStdOut()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ private:
|
||||
p.setCommand(cmd);
|
||||
p.setEnvironment(testEnv);
|
||||
p.runBlocking();
|
||||
return QString::fromUtf8(p.readAllRawStandardOutput());
|
||||
return QString::fromUtf8(p.rawStdOut());
|
||||
}
|
||||
|
||||
private slots:
|
||||
|
@@ -114,7 +114,7 @@ private slots:
|
||||
proc.setCommand({envPath, {}});
|
||||
proc.runBlocking();
|
||||
QCOMPARE(proc.exitCode(), 0);
|
||||
const QByteArray output = proc.readAllRawStandardOutput() + proc.readAllRawStandardError();
|
||||
const QByteArray output = proc.rawStdOut() + proc.rawStdErr();
|
||||
qDebug() << "Process output:" << output;
|
||||
|
||||
QCOMPARE(output.size() > 0, qoutput.size() > 0);
|
||||
@@ -1211,8 +1211,8 @@ void tst_Process::channelForwarding()
|
||||
process.start();
|
||||
QVERIFY(process.waitForFinished());
|
||||
|
||||
const QByteArray output = process.readAllRawStandardOutput();
|
||||
const QByteArray error = process.readAllRawStandardError();
|
||||
const QByteArray output = process.rawStdOut();
|
||||
const QByteArray error = process.rawStdErr();
|
||||
|
||||
QCOMPARE(output.contains(QByteArray(s_outputData)), outputForwarded);
|
||||
QCOMPARE(error.contains(QByteArray(s_errorData)), errorForwarded);
|
||||
|
Reference in New Issue
Block a user