Skip to content
Permalink
Browse files

Prevent double expensive calls to loadFields in OGR

  • Loading branch information
elpaso committed Mar 23, 2021
1 parent e45b819 commit 0391b1515710a48e7eb8c5628ddcbd0908fce5d4
Showing with 9 additions and 4 deletions.
  1. +9 −4 src/core/providers/ogr/qgsogrprovider.cpp
@@ -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;
@@ -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 );

0 comments on commit 0391b15

Please sign in to comment.