Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Flush sink buffers instead of deleting sink/sources in processAlgorithm
Avoids potential issues if processAlgorithm is run in a different
thread
  • Loading branch information
nyalldawson committed Jul 6, 2017
1 parent e0c7daa commit 7a1fd93
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions src/core/processing/qgsnativealgorithms.cpp
Expand Up @@ -134,8 +134,7 @@ bool QgsCentroidAlgorithm::processAlgorithm( QgsProcessingContext &, QgsProcessi
feedback->setProgress( current * step );
current++;
}
mSource.reset();
mSink.reset();
mSink->flushBuffer();
return true;
}

Expand Down Expand Up @@ -268,8 +267,7 @@ bool QgsBufferAlgorithm::processAlgorithm( QgsProcessingContext &, QgsProcessing
mSink->addFeature( f, QgsFeatureSink::FastInsert );
}

mSource.reset();
mSink.reset();
mSink->flushBuffer();
return true;
}

Expand Down Expand Up @@ -427,9 +425,7 @@ bool QgsDissolveAlgorithm::processAlgorithm( QgsProcessingContext &, QgsProcessi
}
}

mSource.reset();
mSink.reset();

mSink->flushBuffer();
return true;
}

Expand Down Expand Up @@ -592,9 +588,7 @@ bool QgsClipAlgorithm::processAlgorithm( QgsProcessingContext &, QgsProcessingFe
feedback->setProgress( 100.0 * static_cast< double >( i ) / clipGeoms.length() );
}
}
mFeatureSource.reset();
mMaskSource.reset();
mSink.reset();
mSink->flushBuffer();
return true;
}

Expand Down Expand Up @@ -751,8 +745,7 @@ bool QgsSubdivideAlgorithm::processAlgorithm( QgsProcessingContext &, QgsProcess
feedback->setProgress( current * step );
current++;
}
mSource.reset();
mSink.reset();
mSink->flushBuffer();
return true;
}

Expand Down Expand Up @@ -844,9 +837,7 @@ bool QgsMultipartToSinglepartAlgorithm::processAlgorithm( QgsProcessingContext &
feedback->setProgress( current * step );
current++;
}
mSource.reset();
mSink.reset();

mSink->flushBuffer();
return true;
}

Expand Down Expand Up @@ -968,10 +959,10 @@ bool QgsExtractByExpressionAlgorithm::processAlgorithm( QgsProcessingContext &,
current++;
}
}

mSource.reset();
mMatchingSink.reset();
mNonMatchingSink.reset();
if ( mMatchingSink )
mMatchingSink->flushBuffer();
if ( mNonMatchingSink )
mNonMatchingSink->flushBuffer();
return true;
}

Expand Down Expand Up @@ -1177,9 +1168,10 @@ bool QgsExtractByAttributeAlgorithm::processAlgorithm( QgsProcessingContext &, Q
}
}

mSource.reset();
mMatchingSink.reset();
mNonMatchingSink.reset();
if ( mMatchingSink )
mMatchingSink->flushBuffer();
if ( mNonMatchingSink )
mNonMatchingSink->flushBuffer();
return true;
}

Expand Down

0 comments on commit 7a1fd93

Please sign in to comment.