Skip to content
Permalink
Browse files
Prevent double expensive calls to loadFields in OGR
(cherry picked from commit 0391b15)
  • Loading branch information
elpaso authored and nyalldawson committed Apr 17, 2021
1 parent 7a74d7f commit 029d24581f4a72ffd6577ea10e99a0ed73e53498
Showing with 9 additions and 4 deletions.
  1. +9 −4 src/core/providers/ogr/qgsogrprovider.cpp
@@ -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;
@@ -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 );

0 comments on commit 029d245

Please sign in to comment.