Skip to content

Commit 6f3ebde

Browse files
committed
Safer iterator closing, by always calling ::close() instead of
directly manipulating mClosed Fixes a crash in the memory data provider (also likely fixes issues in other providers)
1 parent d6eb8ec commit 6f3ebde

11 files changed

+13
-19
lines changed

src/core/providers/memory/qgsmemoryfeatureiterator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ QgsMemoryFeatureIterator::QgsMemoryFeatureIterator( QgsMemoryFeatureSource *sour
3939
catch ( QgsCsException & )
4040
{
4141
// can't reproject mFilterRect
42-
mClosed = true;
42+
close();
4343
return;
4444
}
4545

src/core/qgscachedfeatureiterator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ QgsCachedFeatureIterator::QgsCachedFeatureIterator( QgsVectorLayerCache *vlCache
3232
catch ( QgsCsException & )
3333
{
3434
// can't reproject mFilterRect
35-
mClosed = true;
35+
close();
3636
return;
3737
}
3838
if ( !mFilterRect.isNull() )
@@ -118,7 +118,7 @@ QgsCachedFeatureWriterIterator::QgsCachedFeatureWriterIterator( QgsVectorLayerCa
118118
catch ( QgsCsException & )
119119
{
120120
// can't reproject mFilterRect
121-
mClosed = true;
121+
close();
122122
return;
123123
}
124124
if ( !mFilterRect.isNull() )

src/core/qgsvectorlayerfeatureiterator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator( QgsVectorLayerFeat
124124
catch ( QgsCsException & )
125125
{
126126
// can't reproject mFilterRect
127-
mClosed = true;
127+
close();
128128
return;
129129
}
130130
if ( !mFilterRect.isNull() )

src/providers/arcgisrest/qgsafsfeatureiterator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ QgsAfsFeatureIterator::QgsAfsFeatureIterator( QgsAfsFeatureSource *source, bool
5050
catch ( QgsCsException & )
5151
{
5252
// can't reproject mFilterRect
53-
mClosed = true;
53+
close();
5454
return;
5555
}
5656
}

src/providers/db2/qgsdb2featureiterator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ QgsDb2FeatureIterator::QgsDb2FeatureIterator( QgsDb2FeatureSource *source, bool
4545
catch ( QgsCsException & )
4646
{
4747
// can't reproject mFilterRect
48-
mClosed = true;
48+
close();
4949
return;
5050
}
5151

src/providers/delimitedtext/qgsdelimitedtextfeatureiterator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ QgsDelimitedTextFeatureIterator::QgsDelimitedTextFeatureIterator( QgsDelimitedTe
5050
catch ( QgsCsException & )
5151
{
5252
// can't reproject mFilterRect
53-
mClosed = true;
53+
close();
5454
return;
5555
}
5656

src/providers/gpx/qgsgpxfeatureiterator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ QgsGPXFeatureIterator::QgsGPXFeatureIterator( QgsGPXFeatureSource *source, bool
4040
catch ( QgsCsException & )
4141
{
4242
// can't reproject mFilterRect
43-
mClosed = true;
43+
close();
4444
return;
4545
}
4646

src/providers/mssql/qgsmssqlfeatureiterator.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ QgsMssqlFeatureIterator::QgsMssqlFeatureIterator( QgsMssqlFeatureSource *source,
4545
catch ( QgsCsException & )
4646
{
4747
// can't reproject mFilterRect
48-
mClosed = true;
48+
close();
4949
return;
5050
}
5151

@@ -413,13 +413,7 @@ bool QgsMssqlFeatureIterator::rewind()
413413
if ( !result )
414414
{
415415
QgsDebugMsg( mQuery->lastError().text() );
416-
mQuery.reset();
417-
if ( mDatabase.isOpen() )
418-
mDatabase.close();
419-
420-
iteratorClosed();
421-
422-
mClosed = true;
416+
close();
423417
return false;
424418
}
425419

src/providers/ogr/qgsogrfeatureiterator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool
8888
catch ( QgsCsException & )
8989
{
9090
// can't reproject mFilterRect
91-
mClosed = true;
91+
close();
9292
return;
9393
}
9494

src/providers/virtual/qgsvirtuallayerfeatureiterator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ QgsVirtualLayerFeatureIterator::QgsVirtualLayerFeatureIterator( QgsVirtualLayerF
5454
catch ( QgsCsException & )
5555
{
5656
// can't reproject mFilterRect
57-
mClosed = true;
57+
close();
5858
return;
5959
}
6060

src/providers/wfs/qgswfsfeatureiterator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ QgsWFSFeatureIterator::QgsWFSFeatureIterator( QgsWFSFeatureSource *source,
824824
catch ( QgsCsException & )
825825
{
826826
// can't reproject mFilterRect
827-
mClosed = true;
827+
close();
828828
return;
829829
}
830830

0 commit comments

Comments
 (0)