Skip to content
Permalink
Browse files

Merge pull request #42412 from elpaso/optimization-ogr-avoid-double-l…

…oad-fields-call

Prevent double expensive calls to loadFields in OGR
  • Loading branch information
elpaso authored and nyalldawson committed Mar 26, 2021
1 parent 924c70d commit 6943e4eab995bda9f76a3245900a689d61e4ae78
Showing with 7 additions and 5 deletions.
  1. +7 −5 src/core/providers/ogr/qgsogrprovider.cpp
@@ -2306,6 +2306,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;
@@ -2387,10 +2389,11 @@ 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 )
{
loadFields();
}

invalidateCachedExtent( false );

@@ -7340,4 +7343,3 @@ QgsProviderMetadata::ProviderCapabilities QgsOgrProviderMetadata::providerCapabi
return FileBasedUris;
}
///@endcond

0 comments on commit 6943e4e

Please sign in to comment.