Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix deadlock when number of point cloud files loaded >= available thr…
…eads

This would cause multiple QgsTasks to be created, each of which
uses one thread -- then if the number of tasks matches or exceeds
the number of available threads, then the call to blockingMapped
in QgsPointCloudStatsCalculator will hang forever waiting for
a thread to be freed (which will never happen, since the running
tasks CANNOT complete as they are blocked)

Avoid this by releasing and reserving the current thread
from the QgsPointCloudStatsCalculationTask before performing
the blockingMapped function.
  • Loading branch information
nyalldawson committed May 2, 2023
1 parent 8c911dd commit 914dffb
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/pointcloud/qgspointcloudstatscalculator.cpp
Expand Up @@ -209,7 +209,9 @@ bool QgsPointCloudStatsCalculator::calculateStats( QgsFeedback *feedback, const

feedback->setProgress( 0 );

QThreadPool::globalInstance()->releaseThread();
QVector<QgsPointCloudStatistics> list = QtConcurrent::blockingMapped( nodes, StatsProcessor( mIndex.get(), mRequest, feedback, 100.0 / ( double )nodes.size() ) );
QThreadPool::globalInstance()->reserveThread();

for ( QgsPointCloudStatistics &s : list )
{
Expand Down

0 comments on commit 914dffb

Please sign in to comment.