remove UI objects when a task is deleted

This commit is contained in:
itsmattkc
2019-06-29 02:30:42 -07:00
parent 84720b39cb
commit 2e6b36b2ae
3 changed files with 52 additions and 2 deletions
+16
View File
@@ -30,6 +30,11 @@ TaskManager::TaskManager()
maximum_task_count_ = QThread::idealThreadCount();
}
TaskManager::~TaskManager()
{
Clear();
}
void TaskManager::AddTask(Task* t)
{
// Connect Task's status signal to the Callback
@@ -45,6 +50,17 @@ void TaskManager::AddTask(Task* t)
StartNextWaiting();
}
void TaskManager::Clear()
{
// TODO Cancelling tasks
// Delete Tasks from memory
for (int i=0;i<tasks_.size();i++) {
delete tasks_.at(i);
}
tasks_.clear();
}
void TaskManager::StartNextWaiting()
{
// Count the tasks that are currently active
+32
View File
@@ -42,6 +42,33 @@ public:
*/
TaskManager();
/**
* @brief TaskManager Destructor
*
* Ensures all Tasks are deleted
*/
virtual ~TaskManager();
/**
* @brief Deleted copy constructor
*/
TaskManager(const TaskManager& other) = delete;
/**
* @brief Deleted move constructor
*/
TaskManager(TaskManager&& other) = delete;
/**
* @brief Deleted copy assignment
*/
TaskManager& operator=(const TaskManager& other) = delete;
/**
* @brief Deleted move assignment
*/
TaskManager& operator=(TaskManager&& other) = delete;
/**
* @brief Add a new Task
*
@@ -56,6 +83,11 @@ public:
*/
void AddTask(Task *t);
/**
* @brief Forcibly
*/
void Clear();
signals:
/**
* @brief Signal emitted when a Task is added by AddTask()