Skip to content
Permalink
Browse files

Merge pull request #9207 from mbernasocchi/master

Add safety guard when mDataProvider is not set
  • Loading branch information
m-kuhn committed Feb 20, 2019
2 parents 8eb1c4e + 8ea09b6 commit ddbd06f3f11eef478f6d971a771c31eccde0b86f
Showing with 5 additions and 0 deletions.
  1. +2 −0 python/core/auto_generated/qgsvectorlayer.sip.in
  2. +2 −0 src/core/qgsvectorlayer.cpp
  3. +1 −0 src/core/qgsvectorlayer.h
@@ -1507,6 +1507,8 @@ Returns the list of attributes which make up the layer's primary keys.
%Docstring
Returns feature count including changes which have not yet been committed
If you need only the count of committed features call this method on this layer's provider.

:return: the number of features on this layer or -1 if unknown.
%End

bool setReadOnly( bool readonly = true );
@@ -2891,6 +2891,8 @@ QgsAttributeList QgsVectorLayer::primaryKeyAttributes() const

long QgsVectorLayer::featureCount() const
{
if ( ! mDataProvider )
return -1;
return mDataProvider->featureCount() +
( mEditBuffer ? mEditBuffer->mAddedFeatures.size() - mEditBuffer->mDeletedFeatureIds.size() : 0 );
}
@@ -1397,6 +1397,7 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
/**
* Returns feature count including changes which have not yet been committed
* If you need only the count of committed features call this method on this layer's provider.
* \returns the number of features on this layer or -1 if unknown.
*/
long featureCount() const FINAL;

0 comments on commit ddbd06f

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