Skip to content
Permalink
Browse files

mDoNotResetReading -> mAllowResetReading

  • Loading branch information
elpaso committed Oct 8, 2020
1 parent 505ef99 commit 02c168a29d30a2cc6d29756978177797822bd484
Showing with 13 additions and 13 deletions.
  1. +11 −11 src/core/providers/ogr/qgsogrfeatureiterator.cpp
  2. +2 −2 src/core/providers/ogr/qgsogrfeatureiterator.h
@@ -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() )
{
@@ -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 );
@@ -175,7 +175,7 @@ QgsOgrFeatureIterator::QgsOgrFeatureIterator( QgsOgrFeatureSource *source, bool
}

// spatial query to select features
if ( ! mDoNotResetReading )
if ( mAllowResetReading )
{
if ( !mFilterRect.isNull() )
{
@@ -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 )
{
@@ -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 );
}
@@ -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;
@@ -399,7 +399,7 @@ bool QgsOgrFeatureIterator::fetchFeature( QgsFeature &feature )

void QgsOgrFeatureIterator::resetReading()
{
if ( mDoNotResetReading )
if ( ! mAllowResetReading )
{
return;
}
@@ -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;

0 comments on commit 02c168a

Please sign in to comment.
You can’t perform that action at this time.