aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/git/gitcommand.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/git/gitcommand.cpp')
-rw-r--r--src/plugins/git/gitcommand.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/plugins/git/gitcommand.cpp b/src/plugins/git/gitcommand.cpp
index fed9d81b671..e1f4ac3a948 100644
--- a/src/plugins/git/gitcommand.cpp
+++ b/src/plugins/git/gitcommand.cpp
@@ -112,6 +112,22 @@ void GitCommand::execute()
QLatin1String("Git.action"));
}
+QString GitCommand::msgTimeout(int seconds)
+{
+ return tr("Error: Git timed out after %1s.").arg(seconds);
+}
+
+bool GitCommand::stopProcess(QProcess &p)
+{
+ if (p.state() != QProcess::Running)
+ return true;
+ p.terminate();
+ if (p.waitForFinished(300))
+ return true;
+ p.kill();
+ return p.waitForFinished(300);
+}
+
void GitCommand::run()
{
if (Git::Constants::debug)
@@ -139,10 +155,11 @@ void GitCommand::run()
}
process.closeWriteChannel();
- if (!process.waitForFinished(m_jobs.at(j).timeout * 1000)) {
- process.terminate();
+ const int timeOutSeconds = m_jobs.at(j).timeout;
+ if (!process.waitForFinished(timeOutSeconds * 1000)) {
+ stopProcess(process);
ok = false;
- error += QLatin1String("Error: Git timed out");
+ error += msgTimeout(timeOutSeconds);
break;
}