automatically delete tasks that have completed successfully

This commit is contained in:
itsmattkc
2019-06-30 12:28:40 -07:00
parent ed87e467ae
commit 8e006f3883
3 changed files with 41 additions and 4 deletions
+21 -4
View File
@@ -88,21 +88,38 @@ void TaskManager::StartNextWaiting()
}
}
void TaskManager::DeleteTask(Task *t)
{
// TODO Cancelling tasks?
// Remove instances of Task from queue
tasks_.removeAll(t);
// Destroy Task object
delete t;
}
void TaskManager::TaskCallback(Task::Status status)
{
switch (status) {
case Task::kWaiting:
qDebug() << sender() << "is waiting...";
//qDebug() << sender() << "is waiting...";
break;
case Task::kWorking:
qDebug() << sender() << "is working...";
//qDebug() << sender() << "is working...";
break;
case Task::kFinished:
qDebug() << sender() << "finished successfully.";
//qDebug() << sender() << "finished successfully.";
// The Task has finished, we can start a new one
StartNextWaiting();
DeleteTask(static_cast<Task*>(sender()));
break;
case Task::kError:
qDebug() << sender() << "failed:" << static_cast<Task*>(sender())->error();
//qDebug() << sender() << "failed:" << static_cast<Task*>(sender())->error();
// The Task has finished, we can start a new one
StartNextWaiting();
break;
}