Skip to content

Commit

Permalink
Don't try to continue calculating union steps after cancelation occurs
Browse files Browse the repository at this point in the history
Fixes #43553
  • Loading branch information
nyalldawson committed Jun 8, 2021
1 parent 2a3bcc3 commit 1f25ba5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/analysis/processing/qgsalgorithmsymmetricaldifference.cpp
Expand Up @@ -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 );

Expand Down
4 changes: 4 additions & 0 deletions src/analysis/processing/qgsalgorithmunion.cpp
Expand Up @@ -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 );

Expand Down
6 changes: 6 additions & 0 deletions src/analysis/processing/qgsoverlayutils.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 1f25ba5

Please sign in to comment.