Skip to content

Commit

Permalink
Add deleteAllTasks to manager
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 5, 2016
1 parent b64025d commit 95dbb3a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
5 changes: 5 additions & 0 deletions python/core/qgstaskmanager.sip
Expand Up @@ -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
Expand Down
15 changes: 14 additions & 1 deletion src/core/qgstaskmanager.cpp
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgstaskmanager.h
Expand Up @@ -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
Expand Down

0 comments on commit 95dbb3a

Please sign in to comment.