Skip to content

Commit 0391b15

Browse files
committedMar 23, 2021
Prevent double expensive calls to loadFields in OGR
1 parent e45b819 commit 0391b15

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed
 

‎src/core/providers/ogr/qgsogrprovider.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,6 +2273,8 @@ bool QgsOgrProvider::_setSubsetString( const QString &theSQL, bool updateFeature
22732273
if ( theSQL == mSubsetString && mFeaturesCounted != QgsVectorDataProvider::Uncounted )
22742274
return true;
22752275

2276+
const bool subsetStringHasChanged { theSQL != mSubsetString };
2277+
22762278
if ( !theSQL.isEmpty() )
22772279
{
22782280
QMutex *mutex = nullptr;
@@ -2354,10 +2356,13 @@ bool QgsOgrProvider::_setSubsetString( const QString &theSQL, bool updateFeature
23542356

23552357
mRefreshFeatureCount = updateFeatureCount;
23562358

2357-
// check the validity of the layer
2358-
QgsDebugMsgLevel( QStringLiteral( "checking validity" ), 4 );
2359-
loadFields();
2360-
QgsDebugMsgLevel( QStringLiteral( "Done checking validity" ), 4 );
2359+
// check the validity of the layer if subset string has changed
2360+
if ( subsetStringHasChanged )
2361+
{
2362+
QgsDebugMsgLevel( QStringLiteral( "checking validity" ), 4 );
2363+
loadFields();
2364+
QgsDebugMsgLevel( QStringLiteral( "Done checking validity" ), 4 );
2365+
}
23612366

23622367
invalidateCachedExtent( false );
23632368

0 commit comments

Comments
 (0)
Please sign in to comment.