Skip to content

Commit

Permalink
Don't block when deleting tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 5, 2016
1 parent dcecf44 commit 73e72fa
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/core/qgstaskmanager.cpp
Expand Up @@ -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;
}

Expand Down

0 comments on commit 73e72fa

Please sign in to comment.