Skip to content

Commit

Permalink
Merge pull request #4797 from nyalldawson/flush_sink
Browse files Browse the repository at this point in the history
Move flushBuffer method up to QgsFeatureSink
  • Loading branch information
nyalldawson committed Jun 29, 2017
2 parents 7b1932a + bf3d55c commit fe800e2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
6 changes: 6 additions & 0 deletions python/core/qgsfeaturesink.sip
Expand Up @@ -55,6 +55,12 @@ class QgsFeatureSink
:rtype: bool
%End

virtual bool flushBuffer();
%Docstring
Flushes any internal buffer which may exist in the sink, causing any buffered features to be added to the sink's destination.
:return: false if any buffered features could not be added to the sink.
:rtype: bool
%End
};

QFlags<QgsFeatureSink::Flag> operator|(QgsFeatureSink::Flag f1, QFlags<QgsFeatureSink::Flag> f2);
Expand Down
8 changes: 2 additions & 6 deletions python/core/qgsvectorlayerexporter.sip
Expand Up @@ -124,12 +124,8 @@ class QgsVectorLayerExporter : QgsFeatureSink
Finalizes the export and closes the new created layer.
%End

bool flushBuffer();
%Docstring
Flush the buffer writing the features to the new layer.
.. versionadded:: 3.0
:rtype: bool
%End
virtual bool flushBuffer();


private:
QgsVectorLayerExporter( const QgsVectorLayerExporter &rh );
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgsfeaturesink.h
Expand Up @@ -71,6 +71,11 @@ class CORE_EXPORT QgsFeatureSink
*/
virtual bool addFeatures( QgsFeatureIterator &iterator, QgsFeatureSink::Flags flags = 0 );

/**
* Flushes any internal buffer which may exist in the sink, causing any buffered features to be added to the sink's destination.
* \returns false if any buffered features could not be added to the sink.
*/
virtual bool flushBuffer() { return true; }
};

Q_DECLARE_OPERATORS_FOR_FLAGS( QgsFeatureSink::Flags )
Expand Down
6 changes: 1 addition & 5 deletions src/core/qgsvectorlayerexporter.h
Expand Up @@ -141,11 +141,7 @@ class CORE_EXPORT QgsVectorLayerExporter : public QgsFeatureSink
*/
~QgsVectorLayerExporter();

/**
* Flush the buffer writing the features to the new layer.
* \since QGIS 3.0
*/
bool flushBuffer();
bool flushBuffer() override;

private:

Expand Down

0 comments on commit fe800e2

Please sign in to comment.