Skip to content
Permalink
Browse files
Don't block when deleting tasks
  • Loading branch information
nyalldawson committed Dec 5, 2016
1 parent dcecf44 commit 73e72fa590d321e4e914e58e31c1848211f931cc
Showing with 10 additions and 12 deletions.
  1. +10 −12 src/core/qgstaskmanager.cpp
@@ -228,23 +228,21 @@ bool QgsTaskManager::cleanupAndDeleteTask( QgsTask *task )
if ( !task )
return false;

emit taskAboutToBeDeleted( taskId( task ) );

if ( task->isActive() )
{
task->cancel();

// wait for task to terminate
QMap< long, TaskInfo >::iterator it = mTasks.begin();
for ( ; it != mTasks.end(); ++it )
// delete task when it's terminated
connect( task, SIGNAL( taskCompleted() ), task, SLOT( deleteLater() ) );
connect( task, SIGNAL( taskStopped() ), task, SLOT( deleteLater() ) );
}
else
{
if ( it.value().task == task )
{
it.value().future.waitForFinished();
break;
}
//task already finished, kill it
task->deleteLater();
}

emit taskAboutToBeDeleted( taskId( task ) );

task->deleteLater();
return true;
}

0 comments on commit 73e72fa

Please sign in to comment.