Skip to content

Commit

Permalink
mDoNotResetReading -> mAllowResetReading
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Oct 8, 2020
1 parent 505ef99 commit 02c168a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions src/core/providers/ogr/qgsogrfeatureiterator.cpp
Expand Up @@ -52,10 +52,10 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool
* (see GH #39178) so we need to skip all calls that might reset the reading (rewind) to avoid an endless loop in the
* outer fetching iterator that uses the same connection.
*/
mDoNotResetReading = transaction &&
( source->mDriverName == QLatin1String( "GPKG" ) || source->mDriverName == QLatin1String( "SQLite" ) ) &&
( mRequest.filterType() == QgsFeatureRequest::FilterType::FilterFid
|| mRequest.filterType() == QgsFeatureRequest::FilterType::FilterFids );
mAllowResetReading = ! transaction ||
( source->mDriverName != QLatin1String( "GPKG" ) & source->mDriverName != QLatin1String( "SQLite" ) ) ||
( mRequest.filterType() != QgsFeatureRequest::FilterType::FilterFid
&& mRequest.filterType() != QgsFeatureRequest::FilterType::FilterFids );

for ( const auto &id : mRequest.filterFids() )
{
Expand Down Expand Up @@ -95,7 +95,7 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool
return;
}

if ( ! mDoNotResetReading && !mSource->mSubsetString.isEmpty() )
if ( mAllowResetReading && !mSource->mSubsetString.isEmpty() )
{
mOgrLayerOri = mOgrLayer;
mOgrLayer = QgsOgrProviderUtils::setSubsetString( mOgrLayer, mConn->ds, mSource->mEncoding, mSource->mSubsetString );
Expand Down Expand Up @@ -175,7 +175,7 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool
}

// spatial query to select features
if ( ! mDoNotResetReading )
if ( mAllowResetReading )
{
if ( !mFilterRect.isNull() )
{
Expand Down Expand Up @@ -215,7 +215,7 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool
QStringLiteral( ")" );
}

if ( ! mDoNotResetReading )
if ( mAllowResetReading )
{
if ( OGR_L_SetAttributeFilter( mOgrLayer, mSource->mEncoding->fromUnicode( whereClause ).constData() ) == OGRERR_NONE )
{
Expand All @@ -231,14 +231,14 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool
}

}
else if ( mSource->mSubsetString.isEmpty() && ! mDoNotResetReading )
else if ( mSource->mSubsetString.isEmpty() && mAllowResetReading )
{
OGR_L_SetAttributeFilter( mOgrLayer, nullptr );
}

delete compiler;
}
else if ( mSource->mSubsetString.isEmpty() && ! mDoNotResetReading )
else if ( mSource->mSubsetString.isEmpty() && mAllowResetReading )
{
OGR_L_SetAttributeFilter( mOgrLayer, nullptr );
}
Expand Down Expand Up @@ -267,7 +267,7 @@ bool QgsOgrFeatureIterator::fetchFeatureWithId( QgsFeatureId id, QgsFeature &fea
gdal::ogr_feature_unique_ptr fet;

#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(2,2,0)
if ( ! mDoNotResetReading && !QgsOgrProviderUtils::canDriverShareSameDatasetAmongLayers( mSource->mDriverName ) )
if ( mAllowResetReading && !QgsOgrProviderUtils::canDriverShareSameDatasetAmongLayers( mSource->mDriverName ) )
{
OGRLayerH nextFeatureBelongingLayer;
bool found = false;
Expand Down Expand Up @@ -399,7 +399,7 @@ bool QgsOgrFeatureIterator::fetchFeature( QgsFeature &feature )

void QgsOgrFeatureIterator::resetReading()
{
if ( mDoNotResetReading )
if ( ! mAllowResetReading )
{
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/providers/ogr/qgsogrfeatureiterator.h
Expand Up @@ -103,10 +103,10 @@ class QgsOgrFeatureIterator final: public QgsAbstractFeatureIteratorFromSource<Q
bool mFirstFieldIsFid = false;
QgsFields mFieldsWithoutFid;

/* This flag tells the iterator to skip all calls that might reset the reading (rewind),
/* This flag tells the iterator when to skip all calls that might reset the reading (rewind),
* to be used when the request is for a single fid or for a list of fids and we are inside
* a transaction for SQLITE-based layers */
bool mDoNotResetReading = false;
bool mAllowResetReading = true;

bool fetchFeatureWithId( QgsFeatureId id, QgsFeature &feature ) const;

Expand Down

0 comments on commit 02c168a

Please sign in to comment.