Skip to content
Permalink
Browse files

[bugfix][ogr] Recompute capabilities when subsetfilter is set

Need to re-open in rw mode if mDynamicWriteAccess
  • Loading branch information
elpaso committed Jan 5, 2018
1 parent dd60fcd commit 3edc5472bb18b3cb1e12a50b40c76abfb1e899ca
Showing with 25 additions and 1 deletion.
  1. +20 −1 src/providers/ogr/qgsogrprovider.cpp
  2. +5 −0 src/providers/ogr/qgsogrprovider.h
@@ -607,7 +607,7 @@ bool QgsOgrProvider::setSubsetString( const QString &theSQL, bool updateFeatureC
invalidateCachedExtent( false );

// Changing the filter may change capabilities
computeCapabilities();
emit capabilitiesNeedUpdate();

emit dataChanged();

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

// collect abilities reported by OGR
if ( mOgrLayer )
{

// We want the layer in rw mode or capabilities will be wrong
// If mUpdateModeStackDepth > 0, it means that an updateMode is already active and that we have write access
if ( mUpdateModeStackDepth == 0 )
{
updateModeActivated = _enterUpdateMode( true );
}

// Whilst the OGR documentation (e.g. at
// http://www.gdal.org/ogr/classOGRLayer.html#a17) states "The capability
// codes that can be tested are represented as strings, but #defined
@@ -2318,6 +2327,9 @@ void QgsOgrProvider::computeCapabilities()
}
}

if ( updateModeActivated )
leaveUpdateMode();

mCapabilities = ability;
}

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

// Connect
if ( mode == OpenModeInitial )
connect( this, &QgsOgrProvider::capabilitiesNeedUpdate, this, [ = ]
{
computeCapabilities();
} );

// For debug/testing purposes
if ( !mValid )
setProperty( "_debug_open_mode", "invalid" );
@@ -309,6 +309,11 @@ class QgsOgrProvider : public QgsVectorDataProvider
void setupProxy();
#endif

signals:

//! Emitted when capabilities need to be re-computed
void capabilitiesNeedUpdate( );

};

/**

0 comments on commit 3edc547

Please sign in to comment.
You can’t perform that action at this time.