Skip to content

Commit 6876540

Browse files
committedJun 21, 2013
Close active iterators
1 parent 0c88963 commit 6876540

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed
 

‎src/providers/ogr/qgsogrfeatureiterator.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrProvider* p, const QgsFeatur
3535
: QgsAbstractFeatureIterator( request ), P( p ), ogrDataSource(0), ogrLayer(0), mSubsetStringSet(false)
3636
{
3737
mFeatureFetched = false;
38+
P->mActiveIterators.insert( this );
3839

3940
ogrDataSource = OGROpen( TO8F( P->filePath() ), false, NULL );
4041

@@ -159,6 +160,8 @@ bool QgsOgrFeatureIterator::close()
159160
if ( mClosed )
160161
return false;
161162

163+
P->mActiveIterators.remove( this );
164+
162165
if (mSubsetStringSet)
163166
{
164167
OGR_DS_ReleaseResultSet(ogrDataSource, ogrLayer );

‎src/providers/ogr/qgsogrprovider.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ QgsOgrProvider::QgsOgrProvider( QString const & uri )
209209
, ogrDriver( 0 )
210210
, valid( false )
211211
, featuresCounted( -1 )
212-
, mActiveIterator( 0 )
213212
{
214213
QgsCPLErrorHandler handler;
215214

@@ -362,6 +361,11 @@ QgsOgrProvider::~QgsOgrProvider()
362361
{
363362
// Do we need to close all active iterators here?
364363

364+
foreach ( QgsOgrFeatureIterator* it, mActiveIterators )
365+
{
366+
it->close();
367+
}
368+
365369
if ( ogrLayer != ogrOrigLayer )
366370
{
367371
OGR_DS_ReleaseResultSet( ogrDataSource, ogrLayer );

‎src/providers/ogr/qgsogrprovider.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,5 +339,5 @@ class QgsOgrProvider : public QgsVectorDataProvider
339339
bool syncToDisc();
340340

341341
friend class QgsOgrFeatureIterator;
342-
QgsOgrFeatureIterator* mActiveIterator; //!< pointer to currently active iterator (0 if none)
342+
QSet< QgsOgrFeatureIterator*> mActiveIterators;
343343
};

0 commit comments

Comments
 (0)
Please sign in to comment.