From bad8a15f3b858573bc711cb22e4e02d4ae0167e1 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint <Friedemann.Kleint@nokia.com> Date: Mon, 14 Dec 2009 09:41:38 +0100 Subject: [PATCH] Introduce long timeout. --- src/plugins/perforce/perforceplugin.cpp | 15 +++++++++------ src/plugins/perforce/perforceplugin.h | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 5f5b6c7ca88..6f7a73e05cd 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -69,6 +69,7 @@ #include <QtGui/QMessageBox> enum { p4Timeout = 20000 }; +enum { longTimeoutFactor = 4 }; static const VCSBase::VCSBaseEditorParameters editorParameters[] = { { @@ -866,9 +867,9 @@ static inline QString msgNotStarted(const QString &cmd) return PerforcePlugin::tr("Could not start perforce '%1'. Please check your settings in the preferences.").arg(cmd); } -static inline QString msgTimeout() +static inline QString msgTimeout(int timeOut) { - return PerforcePlugin::tr("Perforce did not respond within timeout limit (%1 ms).").arg(p4Timeout ); + return PerforcePlugin::tr("Perforce did not respond within timeout limit (%1 ms).").arg(timeOut ); } static inline QString msgCrash() @@ -893,7 +894,8 @@ PerforceResponse PerforcePlugin::synchronousProcess(const QString &workingDir, VCSBase::VCSBaseOutputWindow *outputWindow = VCSBase::VCSBaseOutputWindow::instance(); // Run, connect stderr to the output window Utils::SynchronousProcess process; - process.setTimeout(p4Timeout); + const int timeOut = (flags & LongTimeOut) ? longTimeoutFactor * p4Timeout : p4Timeout; + process.setTimeout(timeOut); process.setStdOutCodec(outputCodec); if (flags & OverrideDiffEnvironment) process.setProcessEnvironment(overrideDiffEnvironmentVariable()); @@ -980,10 +982,11 @@ PerforceResponse PerforcePlugin::fullySynchronousProcess(const QString &workingD process.closeWriteChannel(); } - if (!process.waitForFinished(p4Timeout)) { + const int timeOut = (flags & LongTimeOut) ? longTimeoutFactor * p4Timeout : p4Timeout; + if (!process.waitForFinished(timeOut)) { PerforceChecker::ensureProcessStopped(process); response.error = true; - response.message = msgTimeout(); + response.message = msgTimeout(timeOut); return response; } if (process.exitStatus() != QProcess::NormalExit) { @@ -1199,7 +1202,7 @@ bool PerforcePlugin::submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *subm QStringList submitArgs; submitArgs << QLatin1String("submit") << QLatin1String("-i"); const PerforceResponse submitResponse = runP4Cmd(m_settings.topLevelSymLinkTarget(), submitArgs, - RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow|ShowBusyCursor, + LongTimeOut|RunFullySynchronous|CommandToWindow|StdErrToWindow|ErrorToWindow|ShowBusyCursor, QStringList(), changeDescription); if (submitResponse.error) { VCSBase::VCSBaseOutputWindow::instance()->appendError(tr("p4 submit failed: %1").arg(submitResponse.message)); diff --git a/src/plugins/perforce/perforceplugin.h b/src/plugins/perforce/perforceplugin.h index ca184caef21..bd1813a93a4 100644 --- a/src/plugins/perforce/perforceplugin.h +++ b/src/plugins/perforce/perforceplugin.h @@ -146,7 +146,8 @@ private: // Run completely synchronously, no signals emitted RunFullySynchronous = 0x20, IgnoreExitCode = 0x40, - ShowBusyCursor = 0x80 + ShowBusyCursor = 0x80, + LongTimeOut = 0x100 }; // args are passed as command line arguments -- GitLab