VCS: Fix time-out handling for synchronous processes.

Introduce static utilities to Utils::SynchronousProcess
for synchronous processes that mimicks the handling
of Utils::SynchronousProcess (apply timeout after no
more data are available on stdout/stderr as opposed
to waitForFinished()).

Task-number: QTCREATORBUG-777
This commit is contained in:
Friedemann Kleint
2010-03-01 10:06:05 +01:00
parent 1f940786fb
commit a1fed931c4
15 changed files with 125 additions and 92 deletions

View File

@@ -42,6 +42,7 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <utils/submiteditorwidget.h>
#include <utils/checkablemessagebox.h>
#include <utils/synchronousprocess.h>
#include <utils/submitfieldwidget.h>
#include <find/basetextfind.h>
#include <texteditor/fontsettings.h>
@@ -580,18 +581,20 @@ bool VCSBaseSubmitEditor::runSubmitMessageCheckScript(const QString &checkScript
*errorMessage = tr("The check script '%1' could not be started: %2").arg(checkScript, checkProcess.errorString());
return false;
}
if (!checkProcess.waitForFinished()) {
*errorMessage = tr("The check script '%1' could not be run: %2").arg(checkScript, checkProcess.errorString());
QByteArray stdOutData;
QByteArray stdErrData;
if (!Utils::SynchronousProcess::readDataFromProcess(checkProcess, 30000, &stdOutData, &stdErrData)) {
Utils::SynchronousProcess::stopProcess(checkProcess);
*errorMessage = tr("The check script '%1' timed out.").arg(checkScript);
return false;
}
if (checkProcess.exitStatus() != QProcess::NormalExit) {
*errorMessage = tr("The check script '%1' crashed").arg(checkScript);
return false;
}
const QString stdOut = QString::fromLocal8Bit(checkProcess.readAllStandardOutput());
if (!stdOut.isEmpty())
outputWindow->appendSilently(stdOut);
const QString stdErr = QString::fromLocal8Bit(checkProcess.readAllStandardError());
if (!stdOutData.isEmpty())
outputWindow->appendSilently(QString::fromLocal8Bit(stdOutData));
const QString stdErr = QString::fromLocal8Bit(stdErrData);
if (!stdErr.isEmpty())
outputWindow->appendSilently(stdErr);
const int exitCode = checkProcess.exitCode();