aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2017-11-10 12:55:10 +0100
committerhjk <hjk@qt.io>2017-11-10 13:55:06 +0000
commit7c26e3336fe28dc025ca41d2898fc186b6f21439 (patch)
tree037eb29df85e24e55dd9b3f93761754c5fb2a90f /src
parent2d9aa5596dbbf8017aafc928d8efd711f2455d04 (diff)
Kill RunWorker start/stop watchdog times in case of reportFailure
Change-Id: I2eb4d9667482edbaafe6bf780a94e440c2d39881 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Filipe Azevedo <filipe.azevedo@kdab.com> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/projectexplorer/runconfiguration.cpp65
1 files changed, 51 insertions, 14 deletions
diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp
index 8c975a7bbd..9c81c19dbd 100644
--- a/src/plugins/projectexplorer/runconfiguration.cpp
+++ b/src/plugins/projectexplorer/runconfiguration.cpp
@@ -560,6 +560,40 @@ public:
bool canStop() const;
void timerEvent(QTimerEvent *ev) override;
+ void killStartWatchdog()
+ {
+ if (startWatchdogTimerId != -1) {
+ killTimer(startWatchdogTimerId);
+ startWatchdogTimerId = -1;
+ }
+ }
+
+ void killStopWatchdog()
+ {
+ if (stopWatchdogTimerId != -1) {
+ killTimer(stopWatchdogTimerId);
+ stopWatchdogTimerId = -1;
+ }
+ }
+
+ void startStartWatchdog()
+ {
+ killStartWatchdog();
+ killStopWatchdog();
+
+ if (startWatchdogInterval != 0)
+ startWatchdogTimerId = startTimer(startWatchdogInterval);
+ }
+
+ void startStopWatchdog()
+ {
+ killStopWatchdog();
+ killStartWatchdog();
+
+ if (stopWatchdogInterval != 0)
+ stopWatchdogTimerId = startTimer(stopWatchdogInterval);
+ }
+
RunWorker *q;
RunWorkerState state = RunWorkerState::Initialized;
const QPointer<RunControl> runControl;
@@ -1573,17 +1607,21 @@ bool RunWorkerPrivate::canStop() const
void RunWorkerPrivate::timerEvent(QTimerEvent *ev)
{
if (ev->timerId() == startWatchdogTimerId) {
- if (startWatchdogCallback)
+ if (startWatchdogCallback) {
+ killStartWatchdog();
startWatchdogCallback();
- else
+ } else {
q->reportFailure(RunWorker::tr("Worker start timed out."));
+ }
return;
}
if (ev->timerId() == stopWatchdogTimerId) {
- if (stopWatchdogCallback)
+ if (stopWatchdogCallback) {
+ killStopWatchdog();
stopWatchdogCallback();
- else
+ } else {
q->reportFailure(RunWorker::tr("Worker stop timed out."));
+ }
return;
}
}
@@ -1641,9 +1679,8 @@ RunWorker::~RunWorker()
*/
void RunWorker::initiateStart()
{
- if (d->startWatchdogInterval != 0)
- d->startWatchdogTimerId = d->startTimer(d->startWatchdogInterval);
-
+ d->startStartWatchdog();
+ d->runControl->d->debugMessage("Initiate start for " + d->id);
start();
}
@@ -1655,8 +1692,7 @@ void RunWorker::initiateStart()
*/
void RunWorker::reportStarted()
{
- if (d->startWatchdogInterval != 0)
- d->killTimer(d->startWatchdogTimerId);
+ d->killStartWatchdog();
d->runControl->d->onWorkerStarted(this);
emit started();
}
@@ -1669,9 +1705,7 @@ void RunWorker::reportStarted()
*/
void RunWorker::initiateStop()
{
- if (d->stopWatchdogInterval != 0)
- d->stopWatchdogTimerId = d->startTimer(d->stopWatchdogInterval);
-
+ d->startStopWatchdog();
d->runControl->d->debugMessage("Initiate stop for " + d->id);
stop();
}
@@ -1687,8 +1721,7 @@ void RunWorker::initiateStop()
*/
void RunWorker::reportStopped()
{
- if (d->stopWatchdogInterval != 0)
- d->killTimer(d->stopWatchdogTimerId);
+ d->killStopWatchdog();
d->runControl->d->onWorkerStopped(this);
emit stopped();
}
@@ -1702,6 +1735,8 @@ void RunWorker::reportStopped()
*/
void RunWorker::reportDone()
{
+ d->killStartWatchdog();
+ d->killStopWatchdog();
switch (d->state) {
case RunWorkerState::Initialized:
QTC_CHECK(false);
@@ -1727,6 +1762,8 @@ void RunWorker::reportDone()
*/
void RunWorker::reportFailure(const QString &msg)
{
+ d->killStartWatchdog();
+ d->killStopWatchdog();
d->runControl->d->onWorkerFailed(this, msg);
}