Skip to content

Commit

Permalink
Prevent double expensive calls to loadFields in OGR
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Mar 23, 2021
1 parent e45b819 commit 0391b15
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/core/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -2273,6 +2273,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 @@ -2354,10 +2356,13 @@ bool QgsOgrProvider::_setSubsetString( const QString &theSQL, bool updateFeature

mRefreshFeatureCount = updateFeatureCount;

// 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 0391b15

Please sign in to comment.