Skip to content
Permalink
Browse files
Add deleteAllTasks to manager
  • Loading branch information
nyalldawson committed Dec 5, 2016
1 parent b64025d commit 95dbb3a7e3f42b0f36299e8c9d20399871c1de7f
Showing with 24 additions and 1 deletion.
  1. +5 −0 python/core/qgstaskmanager.sip
  2. +14 −1 src/core/qgstaskmanager.cpp
  3. +5 −0 src/core/qgstaskmanager.h
@@ -187,6 +187,11 @@ class QgsTaskManager : QObject
*/
bool deleteTask( QgsTask* task );

/** Deletes all tasks in the manager, first terminating them if they are currently
* running.
*/
void deleteAllTasks();

/** Returns the task with matching ID.
* @param id task ID
* @returns task if found, or nullptr
@@ -184,7 +184,20 @@ bool QgsTaskManager::deleteTask( QgsTask *task )
return result;
}

QgsTask*QgsTaskManager::task( long id ) const
void QgsTaskManager::deleteAllTasks()
{
//first tell all tasks to cancel
cancelAll();

QMutexLocker ml( mTaskMutex );
Q_FOREACH ( QgsTask* task, tasks() )
{
deleteTask( task );
}
emit allTasksFinished();
}

QgsTask* QgsTaskManager::task( long id ) const
{
QMutexLocker ml( mTaskMutex );
return mTasks.value( id ).task;
@@ -218,6 +218,11 @@ class CORE_EXPORT QgsTaskManager : public QObject
*/
bool deleteTask( QgsTask* task );

/** Deletes all tasks in the manager, first terminating them if they are currently
* running.
*/
void deleteAllTasks();

/** Returns the task with matching ID.
* @param id task ID
* @returns task if found, or nullptr

0 comments on commit 95dbb3a

Please sign in to comment.