QThreadPool::cancel was introduced in Qt5.5, so no cancellation

possible for Qt < 5.5

Moral of the story: if you run outdated libraries, you can't
expect full functionality from your apps ;)
This commit is contained in:
Nyall Dawson 2016-11-29 13:14:15 +10:00
parent 5216220872
commit 9b763741b8

View File

@ -83,9 +83,14 @@ void QgsTask::run()
void QgsTask::cancel()
{
mShouldTerminate = true;
#if QT_VERSION < 0x050500
//can't cancel with qt < 5.5
return;
#else
mShouldTerminate = true;
QThreadPool::globalInstance()->cancel( this );
if ( mStatus == Queued || mStatus == OnHold )
{
// immediately terminate unstarted jobs
@ -100,6 +105,7 @@ void QgsTask::cancel()
{
subTask.task->cancel();
}
#endif
}
void QgsTask::hold()
@ -694,7 +700,9 @@ bool QgsTaskManager::cleanupAndDeleteTask( QgsTask *task )
}
else
{
#if QT_VERSION >= 0x050500
QThreadPool::globalInstance()->cancel( task );
#endif
if ( isParent )
{
//task already finished, kill it