Skip to content

Commit

Permalink
support cancelling for slow datasources
Browse files Browse the repository at this point in the history
  • Loading branch information
root676 authored and nyalldawson committed Jul 2, 2020
1 parent b2b8fef commit bf7a47a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/analysis/processing/qgsalgorithmcellstatistics.cpp
Expand Up @@ -121,7 +121,7 @@ void QgsCellStatisticsAlgorithm::initAlgorithm( const QVariantMap & )
addOutput( new QgsProcessingOutputNumber( QStringLiteral( "TOTAL_PIXEL_COUNT" ), QObject::tr( "Total pixel count" ) ) );
}

bool QgsCellStatisticsAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
bool QgsCellStatisticsAlgorithm::prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * feedback )
{
QgsRasterLayer *referenceLayer = parameterAsRasterLayer( parameters, QStringLiteral( "REF_LAYER" ), context );
if ( !referenceLayer )
Expand All @@ -141,6 +141,9 @@ bool QgsCellStatisticsAlgorithm::prepareAlgorithm( const QVariantMap &parameters
rasterLayers.reserve( layers.count() );
for ( QgsMapLayer *l : layers )
{
if(feedback->isCanceled())
break; //in case some slow data sources are loaded

if ( l->type() == QgsMapLayerType::RasterLayer )
{
QgsRasterLayer *layer = qobject_cast< QgsRasterLayer * >( l );
Expand Down

0 comments on commit bf7a47a

Please sign in to comment.