mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-28 00:06:23 -05:00
Merge pull request #9207 from mbernasocchi/master
Add safety guard when mDataProvider is not set
This commit is contained in:
commit
ddbd06f3f1
@ -1507,6 +1507,8 @@ Returns the list of attributes which make up the layer's primary keys.
|
|||||||
%Docstring
|
%Docstring
|
||||||
Returns feature count including changes which have not yet been committed
|
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.
|
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
|
%End
|
||||||
|
|
||||||
bool setReadOnly( bool readonly = true );
|
bool setReadOnly( bool readonly = true );
|
||||||
|
|||||||
@ -2891,6 +2891,8 @@ QgsAttributeList QgsVectorLayer::primaryKeyAttributes() const
|
|||||||
|
|
||||||
long QgsVectorLayer::featureCount() const
|
long QgsVectorLayer::featureCount() const
|
||||||
{
|
{
|
||||||
|
if ( ! mDataProvider )
|
||||||
|
return -1;
|
||||||
return mDataProvider->featureCount() +
|
return mDataProvider->featureCount() +
|
||||||
( mEditBuffer ? mEditBuffer->mAddedFeatures.size() - mEditBuffer->mDeletedFeatureIds.size() : 0 );
|
( 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
|
* 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.
|
* 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;
|
long featureCount() const FINAL;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user