Skip to content

Commit

Permalink
Safer iterator closing, by always calling ::close() instead of
Browse files Browse the repository at this point in the history
directly manipulating mClosed

Fixes a crash in the memory data provider (also likely fixes
issues in other providers)
  • Loading branch information
nyalldawson committed Nov 19, 2017
1 parent d6eb8ec commit 6f3ebde
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/core/providers/memory/qgsmemoryfeatureiterator.cpp
Expand Up @@ -39,7 +39,7 @@ QgsMemoryFeatureIterator::QgsMemoryFeatureIterator( QgsMemoryFeatureSource *sour
catch ( QgsCsException & )
{
// can't reproject mFilterRect
mClosed = true;
close();
return;
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/qgscachedfeatureiterator.cpp
Expand Up @@ -32,7 +32,7 @@ QgsCachedFeatureIterator::QgsCachedFeatureIterator( QgsVectorLayerCache *vlCache
catch ( QgsCsException & )
{
// can't reproject mFilterRect
mClosed = true;
close();
return;
}
if ( !mFilterRect.isNull() )
Expand Down Expand Up @@ -118,7 +118,7 @@ QgsCachedFeatureWriterIterator::QgsCachedFeatureWriterIterator( QgsVectorLayerCa
catch ( QgsCsException & )
{
// can't reproject mFilterRect
mClosed = true;
close();
return;
}
if ( !mFilterRect.isNull() )
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayerfeatureiterator.cpp
Expand Up @@ -124,7 +124,7 @@ QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator( QgsVectorLayerFeat
catch ( QgsCsException & )
{
// can't reproject mFilterRect
mClosed = true;
close();
return;
}
if ( !mFilterRect.isNull() )
Expand Down
2 changes: 1 addition & 1 deletion src/providers/arcgisrest/qgsafsfeatureiterator.cpp
Expand Up @@ -50,7 +50,7 @@ QgsAfsFeatureIterator::QgsAfsFeatureIterator( QgsAfsFeatureSource *source, bool
catch ( QgsCsException & )
{
// can't reproject mFilterRect
mClosed = true;
close();
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/db2/qgsdb2featureiterator.cpp
Expand Up @@ -45,7 +45,7 @@ QgsDb2FeatureIterator::QgsDb2FeatureIterator( QgsDb2FeatureSource *source, bool
catch ( QgsCsException & )
{
// can't reproject mFilterRect
mClosed = true;
close();
return;
}

Expand Down
Expand Up @@ -50,7 +50,7 @@ QgsDelimitedTextFeatureIterator::QgsDelimitedTextFeatureIterator( QgsDelimitedTe
catch ( QgsCsException & )
{
// can't reproject mFilterRect
mClosed = true;
close();
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/providers/gpx/qgsgpxfeatureiterator.cpp
Expand Up @@ -40,7 +40,7 @@ QgsGPXFeatureIterator::QgsGPXFeatureIterator( QgsGPXFeatureSource *source, bool
catch ( QgsCsException & )
{
// can't reproject mFilterRect
mClosed = true;
close();
return;
}

Expand Down
10 changes: 2 additions & 8 deletions src/providers/mssql/qgsmssqlfeatureiterator.cpp
Expand Up @@ -45,7 +45,7 @@ QgsMssqlFeatureIterator::QgsMssqlFeatureIterator( QgsMssqlFeatureSource *source,
catch ( QgsCsException & )
{
// can't reproject mFilterRect
mClosed = true;
close();
return;
}

Expand Down Expand Up @@ -413,13 +413,7 @@ bool QgsMssqlFeatureIterator::rewind()
if ( !result )
{
QgsDebugMsg( mQuery->lastError().text() );
mQuery.reset();
if ( mDatabase.isOpen() )
mDatabase.close();

iteratorClosed();

mClosed = true;
close();
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/providers/ogr/qgsogrfeatureiterator.cpp
Expand Up @@ -88,7 +88,7 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool
catch ( QgsCsException & )
{
// can't reproject mFilterRect
mClosed = true;
close();
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/providers/virtual/qgsvirtuallayerfeatureiterator.cpp
Expand Up @@ -54,7 +54,7 @@ QgsVirtualLayerFeatureIterator::QgsVirtualLayerFeatureIterator( QgsVirtualLayerF
catch ( QgsCsException & )
{
// can't reproject mFilterRect
mClosed = true;
close();
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/providers/wfs/qgswfsfeatureiterator.cpp
Expand Up @@ -824,7 +824,7 @@ QgsWFSFeatureIterator::QgsWFSFeatureIterator( QgsWFSFeatureSource *source,
catch ( QgsCsException & )
{
// can't reproject mFilterRect
mClosed = true;
close();
return;
}

Expand Down

0 comments on commit 6f3ebde

Please sign in to comment.