diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2016-07-05 12:00:59 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2016-07-15 14:16:03 +0000 |
commit | 5efd82468b0802fd0f6993b8a430acc09c6293a9 (patch) | |
tree | 5d03cd6b2d0bd32223b4b0c12015b49200c0fa13 /src/plugins | |
parent | 86882018dd39205ba281d9edcd54008e0b9d4156 (diff) | |
download | qt-creator-5efd82468b0802fd0f6993b8a430acc09c6293a9.tar.gz |
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/plugins')
-rw-r--r-- | src/plugins/android/androidbuildapkstep.cpp | 2 | ||||
-rw-r--r-- | src/plugins/beautifier/artisticstyle/artisticstylesettings.cpp | 6 | ||||
-rw-r--r-- | src/plugins/beautifier/beautifierplugin.cpp | 2 | ||||
-rw-r--r-- | src/plugins/clearcase/clearcaseplugin.cpp | 4 | ||||
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmaketool.cpp | 10 | ||||
-rw-r--r-- | src/plugins/cvs/cvsplugin.cpp | 4 | ||||
-rw-r--r-- | src/plugins/debugger/gdb/coregdbadapter.cpp | 2 | ||||
-rw-r--r-- | src/plugins/git/gitclient.cpp | 8 | ||||
-rw-r--r-- | src/plugins/ios/iosprobe.cpp | 2 | ||||
-rw-r--r-- | src/plugins/mercurial/mercurialclient.cpp | 2 | ||||
-rw-r--r-- | src/plugins/perforce/perforceplugin.cpp | 4 | ||||
-rw-r--r-- | src/plugins/projectexplorer/abstractmsvctoolchain.cpp | 2 | ||||
-rw-r--r-- | src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp | 8 | ||||
-rw-r--r-- | src/plugins/projectexplorer/msvctoolchain.cpp | 21 | ||||
-rw-r--r-- | src/plugins/subversion/subversionplugin.cpp | 4 | ||||
-rw-r--r-- | src/plugins/texteditor/generichighlighter/highlightersettings.cpp | 2 |
16 files changed, 41 insertions, 42 deletions
diff --git a/src/plugins/android/androidbuildapkstep.cpp b/src/plugins/android/androidbuildapkstep.cpp index 698dc98aa0..e5593b567c 100644 --- a/src/plugins/android/androidbuildapkstep.cpp +++ b/src/plugins/android/androidbuildapkstep.cpp @@ -305,7 +305,7 @@ QAbstractItemModel *AndroidBuildApkStep::keystoreCertificates() QMessageBox::critical(0, tr("Error"), tr("Invalid password.")); m_keystorePasswd.clear(); } - rawCerts = response.stdOut; + rawCerts = response.stdOut(); } return new CertificatesModel(rawCerts, this); } diff --git a/src/plugins/beautifier/artisticstyle/artisticstylesettings.cpp b/src/plugins/beautifier/artisticstyle/artisticstylesettings.cpp index 52a546860c..b001403679 100644 --- a/src/plugins/beautifier/artisticstyle/artisticstylesettings.cpp +++ b/src/plugins/beautifier/artisticstyle/artisticstylesettings.cpp @@ -85,10 +85,10 @@ static int updateVersionHelper(const QString &command) return 0; // Astyle prints the version on stdout or stderr, depending on platform - const int version = parseVersion(response.stdOut.trimmed()); + const int version = parseVersion(response.stdOut().trimmed()); if (version != 0) return version; - return parseVersion(response.stdErr.trimmed()); + return parseVersion(response.stdErr().trimmed()); } void ArtisticStyleSettings::updateVersion() @@ -176,7 +176,7 @@ void ArtisticStyleSettings::createDocumentationFile() const stream.writeStartElement(Constants::DOCUMENTATION_XMLROOT); // astyle writes its output to 'error'... - const QStringList lines = response.stdErr.split(QLatin1Char('\n')); + const QStringList lines = response.stdErr().split(QLatin1Char('\n')); QStringList keys; QStringList docu; for (QString line : lines) { diff --git a/src/plugins/beautifier/beautifierplugin.cpp b/src/plugins/beautifier/beautifierplugin.cpp index ee9bbf650f..043881b219 100644 --- a/src/plugins/beautifier/beautifierplugin.cpp +++ b/src/plugins/beautifier/beautifierplugin.cpp @@ -104,7 +104,7 @@ FormatTask format(FormatTask task) task.error = BeautifierPlugin::tr("Failed to format: %1.").arg(response.exitMessage(executable, 5)); return task; } - const QString output = response.stdErr; + const QString output = response.stdErr(); if (!output.isEmpty()) task.error = executable + QLatin1String(": ") + output; diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp index 8071365aa8..2351e6bbb2 100644 --- a/src/plugins/clearcase/clearcaseplugin.cpp +++ b/src/plugins/clearcase/clearcaseplugin.cpp @@ -1480,8 +1480,8 @@ ClearCasePlugin::runCleartool(const QString &workingDir, response.error = sp_resp.result != SynchronousProcessResponse::Finished; if (response.error) response.message = sp_resp.exitMessage(executable, timeOutS); - response.stdErr = sp_resp.stdErr; - response.stdOut = sp_resp.stdOut; + response.stdErr = sp_resp.stdErr(); + response.stdOut = sp_resp.stdOut(); return response; } diff --git a/src/plugins/cmakeprojectmanager/cmaketool.cpp b/src/plugins/cmakeprojectmanager/cmaketool.cpp index 55685b0889..5f140ac84f 100644 --- a/src/plugins/cmakeprojectmanager/cmaketool.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketool.cpp @@ -153,7 +153,7 @@ QStringList CMakeTool::supportedGenerators() const Utils::SynchronousProcessResponse response = run(QLatin1String("--help")); if (response.result == Utils::SynchronousProcessResponse::Finished) { bool inGeneratorSection = false; - const QStringList lines = response.stdOut.split(QLatin1Char('\n')); + const QStringList lines = response.stdOut().split(QLatin1Char('\n')); foreach (const QString &line, lines) { if (line.isEmpty()) continue; @@ -188,19 +188,19 @@ TextEditor::Keywords CMakeTool::keywords() Utils::SynchronousProcessResponse response; response = run(QLatin1String("--help-command-list")); if (response.result == Utils::SynchronousProcessResponse::Finished) - m_functions = response.stdOut.split(QLatin1Char('\n')); + m_functions = response.stdOut().split(QLatin1Char('\n')); response = run(QLatin1String("--help-commands")); if (response.result == Utils::SynchronousProcessResponse::Finished) - parseFunctionDetailsOutput(response.stdOut); + parseFunctionDetailsOutput(response.stdOut()); response = run(QLatin1String("--help-property-list")); if (response.result == Utils::SynchronousProcessResponse::Finished) - m_variables = parseVariableOutput(response.stdOut); + m_variables = parseVariableOutput(response.stdOut()); response = run(QLatin1String("--help-variable-list")); if (response.result == Utils::SynchronousProcessResponse::Finished) { - m_variables.append(parseVariableOutput(response.stdOut)); + m_variables.append(parseVariableOutput(response.stdOut())); m_variables = Utils::filteredUnique(m_variables); Utils::sort(m_variables); } diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp index 9f4097ebb1..336a45f6a8 100644 --- a/src/plugins/cvs/cvsplugin.cpp +++ b/src/plugins/cvs/cvsplugin.cpp @@ -1140,8 +1140,8 @@ CvsResponse CvsPlugin::runCvs(const QString &workingDirectory, timeOutS, flags, outputCodec); response.result = CvsResponse::OtherError; - response.stdErr = sp_resp.stdErr; - response.stdOut = sp_resp.stdOut; + response.stdErr = sp_resp.stdErr(); + response.stdOut = sp_resp.stdOut(); switch (sp_resp.result) { case SynchronousProcessResponse::Finished: response.result = CvsResponse::Ok; diff --git a/src/plugins/debugger/gdb/coregdbadapter.cpp b/src/plugins/debugger/gdb/coregdbadapter.cpp index b7a5428571..4534c295a5 100644 --- a/src/plugins/debugger/gdb/coregdbadapter.cpp +++ b/src/plugins/debugger/gdb/coregdbadapter.cpp @@ -142,7 +142,7 @@ GdbCoreEngine::readExecutableNameFromCore(const QString &debuggerCommand, const SynchronousProcessResponse response = proc.runBlocking(debuggerCommand, args); if (response.result == SynchronousProcessResponse::Finished) { - QString output = response.stdOut; + QString output = response.stdOut(); // Core was generated by `/data/dev/creator-2.6/bin/qtcreator'. // Program terminated with signal 11, Segmentation fault. int pos1 = output.indexOf("Core was generated by"); diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index e903a58d07..b526fb980e 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -473,8 +473,8 @@ public: // No conflicts => do nothing if (response.result == SynchronousProcessResponse::Finished) return; - handler.readStdOut(response.stdOut); - handler.readStdErr(response.stdErr); + handler.readStdOut(response.stdOut()); + handler.readStdErr(response.stdErr()); } private: @@ -1543,7 +1543,7 @@ bool GitClient::executeSynchronousStash(const QString &workingDirectory, const SynchronousProcessResponse response = vcsSynchronousExec(workingDirectory, arguments, flags); const bool rc = response.result == SynchronousProcessResponse::Finished; if (!rc) - msgCannotRun(arguments, workingDirectory, response.stdErr.toLocal8Bit(), errorMessage); + msgCannotRun(arguments, workingDirectory, response.rawStdErr, errorMessage); return rc; } @@ -2119,7 +2119,7 @@ QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryUR QString headSha; // split "82bfad2f51d34e98b18982211c82220b8db049b<tab>refs/heads/master" bool headFound = false; - foreach (const QString &line, resp.stdOut.split('\n')) { + foreach (const QString &line, resp.stdOut().split('\n')) { if (line.endsWith("\tHEAD")) { QTC_CHECK(headSha.isNull()); headSha = line.left(line.indexOf('\t')); diff --git a/src/plugins/ios/iosprobe.cpp b/src/plugins/ios/iosprobe.cpp index 47c4e2c7a7..a8be1f7b2a 100644 --- a/src/plugins/ios/iosprobe.cpp +++ b/src/plugins/ios/iosprobe.cpp @@ -104,7 +104,7 @@ void IosProbe::detectDeveloperPaths() if (response.result != Utils::SynchronousProcessResponse::Finished) { qCWarning(probeLog) << QString::fromLatin1("Could not detect selected xcode with /usr/bin/xcode-select"); } else { - QString path = response.stdOut; + QString path = response.stdOut(); path.chop(1); addDeveloperPath(path); } diff --git a/src/plugins/mercurial/mercurialclient.cpp b/src/plugins/mercurial/mercurialclient.cpp index 30af8ba98e..abc4835ed8 100644 --- a/src/plugins/mercurial/mercurialclient.cpp +++ b/src/plugins/mercurial/mercurialclient.cpp @@ -157,7 +157,7 @@ bool MercurialClient::synchronousPull(const QString &workingDir, const QString & workingDir, vcsBinary(), args, vcsTimeoutS(), flags, 0, env); const bool ok = resp.result == SynchronousProcessResponse::Finished; - parsePullOutput(resp.stdOut.trimmed()); + parsePullOutput(resp.stdOut().trimmed()); return ok; } diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 5696e55760..a351014293 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -1016,8 +1016,8 @@ PerforceResponse PerforcePlugin::synchronousProcess(const QString &workingDir, PerforceResponse response; response.error = true; response.exitCode = sp_resp.exitCode; - response.stdErr = sp_resp.stdErr; - response.stdOut = sp_resp.stdOut; + response.stdErr = sp_resp.stdErr(); + response.stdOut = sp_resp.stdOut(); switch (sp_resp.result) { case SynchronousProcessResponse::Finished: response.error = false; diff --git a/src/plugins/projectexplorer/abstractmsvctoolchain.cpp b/src/plugins/projectexplorer/abstractmsvctoolchain.cpp index d7eb341d5b..34436b892c 100644 --- a/src/plugins/projectexplorer/abstractmsvctoolchain.cpp +++ b/src/plugins/projectexplorer/abstractmsvctoolchain.cpp @@ -286,7 +286,7 @@ bool AbstractMsvcToolChain::generateEnvironmentSettings(Utils::Environment &env, } // The SDK/MSVC scripts do not return exit codes != 0. Check on stdout. - const QString stdOut = response.stdOut; + const QString stdOut = response.stdOut(); // // Now parse the file to get the environment settings diff --git a/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp b/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp index 59487384c1..25d009908b 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardscriptgenerator.cpp @@ -116,15 +116,15 @@ static bool if (response.result != Utils::SynchronousProcessResponse::Finished) { *errorMessage = QString::fromLatin1("Generator script failed: %1") .arg(response.exitMessage(binary, 30)); - if (!response.stdErr.isEmpty()) { + const QString stdErr = response.stdErr(); + if (!stdErr.isEmpty()) { errorMessage->append(QLatin1Char('\n')); - errorMessage->append(response.stdErr); + errorMessage->append(stdErr); } return false; } if (stdOut) { - *stdOut = response.stdOut; - stdOut->remove(QLatin1Char('\r')); + *stdOut = response.stdOut(); if (CustomWizard::verbose()) qDebug("Output: '%s'\n", qPrintable(*stdOut)); } diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index bb084b644e..6398ef87ad 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -253,18 +253,17 @@ QByteArray MsvcToolChain::msvcPredefinedMacros(const QStringList cxxflags, response.exitCode != 0) return predefinedMacros; - const QStringList output = response.stdOut.split('\n'); + const QStringList output = Utils::filtered(response.stdOut().split('\n'), + [](const QString &s) { return s.startsWith('V'); }); foreach (const QString& line, output) { - if (line.startsWith('V')) { - QStringList split = line.split('='); - const QString key = split.at(0).mid(1); - QString value = split.at(1); - predefinedMacros += "#define "; - predefinedMacros += key.toUtf8(); - predefinedMacros += ' '; - predefinedMacros += value.toUtf8(); - predefinedMacros += '\n'; - } + QStringList split = line.split('='); + const QString key = split.at(0).mid(1); + QString value = split.at(1); + predefinedMacros += "#define "; + predefinedMacros += key.toUtf8(); + predefinedMacros += ' '; + predefinedMacros += value.toUtf8(); + predefinedMacros += '\n'; } if (debug) qDebug() << "msvcPredefinedMacros" << predefinedMacros; diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index 96c66229eb..d5b0f90e4b 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -892,8 +892,8 @@ SubversionResponse SubversionPlugin::runSvn(const QString &workingDir, response.error = sp_resp.result != SynchronousProcessResponse::Finished; if (response.error) response.message = sp_resp.exitMessage(executable.toString(), timeOutS); - response.stdErr = sp_resp.stdErr; - response.stdOut = sp_resp.stdOut; + response.stdErr = sp_resp.stdErr(); + response.stdOut = sp_resp.stdOut(); return response; } diff --git a/src/plugins/texteditor/generichighlighter/highlightersettings.cpp b/src/plugins/texteditor/generichighlighter/highlightersettings.cpp index dcfa90593f..42e9ca3c26 100644 --- a/src/plugins/texteditor/generichighlighter/highlightersettings.cpp +++ b/src/plugins/texteditor/generichighlighter/highlightersettings.cpp @@ -74,7 +74,7 @@ QString findFallbackDefinitionsLocation() Utils::SynchronousProcessResponse response = process.runBlocking(program, QStringList(QLatin1String("--prefix"))); if (response.result == Utils::SynchronousProcessResponse::Finished) { - QString output = response.stdOut; + QString output = response.stdOut(); output.remove(QLatin1Char('\n')); for (int i = 0; i < kateSyntaxCount; ++i) { dir.setPath(output + kateSyntax[i]); |