Skip to content
Permalink
Browse files

support cancelling for slow datasources

  • Loading branch information
root676 authored and nyalldawson committed Jul 2, 2020
1 parent b2b8fef commit bf7a47a8848f753f9e1a687c20d1602759dbcc0c
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/analysis/processing/qgsalgorithmcellstatistics.cpp
@@ -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 )
@@ -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 );

0 comments on commit bf7a47a

Please sign in to comment.
You can’t perform that action at this time.