Skip to content

Commit

Permalink
Task manager deprecation warning fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 2, 2020
1 parent a2f37cc commit f9f1ad7
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/core/qgstaskmanager.cpp
Expand Up @@ -684,8 +684,11 @@ void QgsTaskManager::taskStatusChanged( int status )
mTaskMutex->lock();
QgsTaskRunnableWrapper *runnable = mTasks.value( id ).runnable;
mTaskMutex->unlock();
if ( runnable )
QThreadPool::globalInstance()->cancel( runnable );
if ( runnable && QThreadPool::globalInstance()->tryTake( runnable ) )
{
delete runnable;
mTasks[ id ].runnable = nullptr;
}

if ( status == QgsTask::Terminated || status == QgsTask::Complete )
{
Expand Down Expand Up @@ -788,8 +791,12 @@ bool QgsTaskManager::cleanupAndDeleteTask( QgsTask *task )
}
else
{
if ( runnable )
QThreadPool::globalInstance()->cancel( runnable );
if ( runnable && QThreadPool::globalInstance()->tryTake( runnable ) )
{
delete runnable;
mTasks[ id ].runnable = nullptr;
}

if ( isParent )
{
//task already finished, kill it
Expand Down

0 comments on commit f9f1ad7

Please sign in to comment.