Commit 4fa869f6 authored by hjk's avatar hjk

ProjectExplorer: Provide optional callbacks to RunWorker timeouts

Useful in some more complex setups.

Defaults to the tradionally unconditional reportFailure().

Change-Id: I26acaace1fa1e12caf83b785e4be539d8af7eb73
Reviewed-by: default avatarFilipe Azevedo <filipe.azevedo@kdab.com>
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
parent eab3a245
......@@ -570,8 +570,10 @@ public:
QVariantMap data;
int startWatchdogInterval = 0;
int startWatchdogTimerId = -1;
std::function<void()> startWatchdogCallback;
int stopWatchdogInterval = 0; // 5000;
int stopWatchdogTimerId = -1;
std::function<void()> stopWatchdogCallback;
bool supportsReRunning = true;
bool essential = false;
};
......@@ -1562,11 +1564,17 @@ bool RunWorkerPrivate::canStop() const
void RunWorkerPrivate::timerEvent(QTimerEvent *ev)
{
if (ev->timerId() == startWatchdogTimerId) {
q->reportFailure(tr("Worker start timed out."));
if (startWatchdogCallback)
startWatchdogCallback();
else
q->reportFailure(tr("Worker start timed out."));
return;
}
if (ev->timerId() == stopWatchdogTimerId) {
q->reportFailure(tr("Worker stop timed out."));
if (stopWatchdogCallback)
stopWatchdogCallback();
else
q->reportFailure(tr("Worker stop timed out."));
return;
}
}
......@@ -1760,14 +1768,16 @@ void RunWorker::setId(const QString &id)
d->id = id;
}
void RunWorker::setStartTimeout(int ms)
void RunWorker::setStartTimeout(int ms, const std::function<void()> &callback)
{
d->startWatchdogInterval = ms;
d->startWatchdogCallback = callback;
}
void RunWorker::setStopTimeout(int ms)
void RunWorker::setStopTimeout(int ms, const std::function<void()> &callback)
{
d->stopWatchdogInterval = ms;
d->stopWatchdogCallback = callback;
}
void RunWorker::recordData(const QString &channel, const QVariant &data)
......
......@@ -347,8 +347,8 @@ public:
void setDisplayName(const QString &id) { setId(id); } // FIXME: Obsoleted by setId.
void setId(const QString &id);
void setStartTimeout(int ms);
void setStopTimeout(int ms);
void setStartTimeout(int ms, const std::function<void()> &callback = {});
void setStopTimeout(int ms, const std::function<void()> &callback = {});
void recordData(const QString &channel, const QVariant &data);
QVariant recordedData(const QString &channel) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment