[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kdevplatform/1.5] vcs/dvcs: Make it possible to kill DVcsJobs.
From:       Milian Wolff <mail () milianw ! de>
Date:       2013-01-31 21:19:16
Message-ID: 20130131211916.A2CFAA6091 () git ! kde ! org
[Download RAW message or body]

Git commit 4e67d5569b7a57afa6af4ddd418d1ba2645a3d2e by Milian Wolff.
Committed on 31/01/2013 at 22:16.
Pushed by mwolff into branch '1.5'.

Make it possible to kill DVcsJobs.

This is a safety measure, if a DVcsJob would be running and we close
KDevelop we cannot properly stop it. Then if result comes in we
might try to access our platform API in an invalid state.

This is the same reason why we see issues such as shown in bug
309715 - there for the CTestFindJob.

M  +17   -0    vcs/dvcs/dvcsjob.cpp
M  +3    -1    vcs/dvcs/dvcsjob.h

http://commits.kde.org/kdevplatform/4e67d5569b7a57afa6af4ddd418d1ba2645a3d2e

diff --git a/vcs/dvcs/dvcsjob.cpp b/vcs/dvcs/dvcsjob.cpp
index 07f2e03..d05d58f 100644
--- a/vcs/dvcs/dvcsjob.cpp
+++ b/vcs/dvcs/dvcsjob.cpp
@@ -70,6 +70,7 @@ DVcsJob::DVcsJob(const QDir& workingDir, IPlugin* parent, OutputJob::OutputJobVe
     d->childproc->setWorkingDirectory(workingDir.absolutePath());
     d->model = new OutputModel;
     setModel(d->model);
+    setCapabilities(Killable);
     
     connect(d->childproc, SIGNAL(finished(int,QProcess::ExitStatus)),
             SLOT(slotProcessExited(int,QProcess::ExitStatus)));
@@ -289,6 +290,22 @@ DVcsJob& DVcsJob::operator<<(const QList< KUrl >& urls)
     return *this;
 }
 
+bool DVcsJob::doKill()
+{
+    if (d->childproc->state() == QProcess::NotRunning) {
+        return true;
+    }
+
+    static const int terminateKillTimeout = 1000; // ms
+    d->childproc->terminate();
+    bool terminated = d->childproc->waitForFinished( terminateKillTimeout );
+    if( !terminated ) {
+        d->childproc->kill();
+        terminated = d->childproc->waitForFinished( terminateKillTimeout );
+    }
+    return terminated;
+}
+
 void DVcsJob::jobIsReady()
 {
     emit readyForParsing(this); //let parsers to set status
diff --git a/vcs/dvcs/dvcsjob.h b/vcs/dvcs/dvcsjob.h
index efd874a..fa8c804 100644
--- a/vcs/dvcs/dvcsjob.h
+++ b/vcs/dvcs/dvcsjob.h
@@ -212,8 +212,10 @@ private Q_SLOTS:
     void slotProcessExited(int exitCode, QProcess::ExitStatus exitStatus);
     void slotReceivedStdout();
 
+protected:
+    virtual bool doKill();
+
 private:
-    
     void jobIsReady();
     DVcsJobPrivate* const d;
 };
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic