Skip to content
Permalink
Browse files
Don't try to continue calculating union steps after cancelation occurs
Fixes #43553
  • Loading branch information
nyalldawson committed Jun 8, 2021
1 parent 2a3bcc3 commit 1f25ba5dbc58bc2f2efd1d930a6104110abe1569
@@ -91,6 +91,8 @@ QVariantMap QgsSymmetricalDifferenceAlgorithm::processAlgorithm( const QVariantM
int total = sourceA->featureCount() + sourceB->featureCount();

QgsOverlayUtils::difference( *sourceA, *sourceB, *sink, context, feedback, count, total, QgsOverlayUtils::OutputAB );
if ( feedback->isCanceled() )
return outputs;

QgsOverlayUtils::difference( *sourceB, *sourceA, *sink, context, feedback, count, total, QgsOverlayUtils::OutputBA );

@@ -106,8 +106,12 @@ QVariantMap QgsUnionAlgorithm::processAlgorithm( const QVariantMap &parameters,
int total = sourceA->featureCount() * 2 + sourceB->featureCount();

QgsOverlayUtils::intersection( *sourceA, *sourceB, *sink, context, feedback, count, total, fieldIndicesA, fieldIndicesB );
if ( feedback->isCanceled() )
return outputs;

QgsOverlayUtils::difference( *sourceA, *sourceB, *sink, context, feedback, count, total, QgsOverlayUtils::OutputAB );
if ( feedback->isCanceled() )
return outputs;

QgsOverlayUtils::difference( *sourceB, *sourceA, *sink, context, feedback, count, total, QgsOverlayUtils::OutputBA );

@@ -89,6 +89,8 @@ void QgsOverlayUtils::difference( const QgsFeatureSource &sourceA, const QgsFeat
if ( outputAttrs != OutputBA )
requestB.setDestinationCrs( sourceA.sourceCrs(), context.transformContext() );
QgsSpatialIndex indexB( sourceB.getFeatures( requestB ), feedback );
if ( feedback->isCanceled() )
return;

int fieldsCountA = sourceA.fields().count();
int fieldsCountB = sourceB.fields().count();
@@ -202,6 +204,8 @@ void QgsOverlayUtils::intersection( const QgsFeatureSource &sourceA, const QgsFe

QgsFeature outFeat;
QgsSpatialIndex indexB( sourceB.getFeatures( request ), feedback );
if ( feedback->isCanceled() )
return;

if ( totalCount == 0 )
totalCount = 1; // avoid division by zero
@@ -415,6 +419,8 @@ void QgsOverlayUtils::resolveOverlaps( const QgsFeatureSource &source, QgsFeatur
++count;
feedback->setProgress( count / ( double ) totalCount * 100. );
}
if ( feedback->isCanceled() )
return;

// release some memory of structures we don't need anymore

0 comments on commit 1f25ba5

Please sign in to comment.