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 ae83444 commit b1f50bbc2cefe593918b73af7d2b92ffac9b764d
@@ -96,6 +96,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 );

@@ -90,6 +90,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();
@@ -203,6 +205,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
@@ -416,6 +420,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 b1f50bb

Please sign in to comment.