Skip to content

Commit

Permalink
Prevent double expensive calls to loadFields in OGR
Browse files Browse the repository at this point in the history
(cherry picked from commit 0391b15)
  • Loading branch information
elpaso authored and nyalldawson committed Apr 17, 2021
1 parent 7a74d7f commit 029d245
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/core/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -2214,6 +2214,8 @@ bool QgsOgrProvider::_setSubsetString( const QString &theSQL, bool updateFeature
if ( theSQL == mSubsetString && mFeaturesCounted != QgsVectorDataProvider::Uncounted )
return true;

const bool subsetStringHasChanged { theSQL != mSubsetString };

if ( !theSQL.isEmpty() )
{
QMutex *mutex = nullptr;
Expand Down Expand Up @@ -2300,10 +2302,13 @@ bool QgsOgrProvider::_setSubsetString( const QString &theSQL, bool updateFeature
recalculateFeatureCount();
}

// check the validity of the layer
QgsDebugMsgLevel( QStringLiteral( "checking validity" ), 4 );
loadFields();
QgsDebugMsgLevel( QStringLiteral( "Done checking validity" ), 4 );
// check the validity of the layer if subset string has changed
if ( subsetStringHasChanged )
{
QgsDebugMsgLevel( QStringLiteral( "checking validity" ), 4 );
loadFields();
QgsDebugMsgLevel( QStringLiteral( "Done checking validity" ), 4 );
}

invalidateCachedExtent( false );

Expand Down

0 comments on commit 029d245

Please sign in to comment.