From 3820fb2600ab468b1fe968162bc54f1afe6dafaa Mon Sep 17 00:00:00 2001 From: eelke Date: Tue, 29 Jan 2019 19:39:21 +0100 Subject: [PATCH] RunControllableTask now also properly catches Exceptions and reports them through the Future. --- core/RunControllableTask.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/core/RunControllableTask.h b/core/RunControllableTask.h index 6cca6ae..e696334 100644 --- a/core/RunControllableTask.h +++ b/core/RunControllableTask.h @@ -34,14 +34,23 @@ public: return; } TaskControl control(this); - result = this->task->run(control); - if (!this->isCanceled()) { - this->reportResult(result); + try { + result = this->task->run(control); + if (!this->isCanceled()) { + this->reportResult(result); + } + } catch (QException &e) { + reportException(e); + } catch (...) { + reportException(QUnhandledException()); } + this->reportFinished(); } - T result; +private: + T result; ControllableTask *task; }; + #endif // RUNCONTROLLABLETASK_H