Skip to content

Commit 3edc547

Browse files
committedJan 5, 2018
[bugfix][ogr] Recompute capabilities when subsetfilter is set
Need to re-open in rw mode if mDynamicWriteAccess
1 parent dd60fcd commit 3edc547

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
 

‎src/providers/ogr/qgsogrprovider.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ bool QgsOgrProvider::setSubsetString( const QString &theSQL, bool updateFeatureC
607607
invalidateCachedExtent( false );
608608

609609
// Changing the filter may change capabilities
610-
computeCapabilities();
610+
emit capabilitiesNeedUpdate();
611611

612612
emit dataChanged();
613613

@@ -2186,10 +2186,19 @@ QgsVectorDataProvider::Capabilities QgsOgrProvider::capabilities() const
21862186
void QgsOgrProvider::computeCapabilities()
21872187
{
21882188
QgsVectorDataProvider::Capabilities ability = nullptr;
2189+
bool updateModeActivated = false;
21892190

21902191
// collect abilities reported by OGR
21912192
if ( mOgrLayer )
21922193
{
2194+
2195+
// We want the layer in rw mode or capabilities will be wrong
2196+
// If mUpdateModeStackDepth > 0, it means that an updateMode is already active and that we have write access
2197+
if ( mUpdateModeStackDepth == 0 )
2198+
{
2199+
updateModeActivated = _enterUpdateMode( true );
2200+
}
2201+
21932202
// Whilst the OGR documentation (e.g. at
21942203
// http://www.gdal.org/ogr/classOGRLayer.html#a17) states "The capability
21952204
// codes that can be tested are represented as strings, but #defined
@@ -2318,6 +2327,9 @@ void QgsOgrProvider::computeCapabilities()
23182327
}
23192328
}
23202329

2330+
if ( updateModeActivated )
2331+
leaveUpdateMode();
2332+
23212333
mCapabilities = ability;
23222334
}
23232335

@@ -4038,6 +4050,13 @@ void QgsOgrProvider::open( OpenMode mode )
40384050
}
40394051
}
40404052

4053+
// Connect
4054+
if ( mode == OpenModeInitial )
4055+
connect( this, &QgsOgrProvider::capabilitiesNeedUpdate, this, [ = ]
4056+
{
4057+
computeCapabilities();
4058+
} );
4059+
40414060
// For debug/testing purposes
40424061
if ( !mValid )
40434062
setProperty( "_debug_open_mode", "invalid" );

‎src/providers/ogr/qgsogrprovider.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,11 @@ class QgsOgrProvider : public QgsVectorDataProvider
309309
void setupProxy();
310310
#endif
311311

312+
signals:
313+
314+
//! Emitted when capabilities need to be re-computed
315+
void capabilitiesNeedUpdate( );
316+
312317
};
313318

314319
/**

0 commit comments

Comments
 (0)
Please sign in to comment.