Bug report #17678
QgsVectorLayer::updateFeature fails when currentFeature.hasGeometry() == 0
| Status: | Closed | ||
|---|---|---|---|
| Priority: | Normal | ||
| Assignee: | - | ||
| Category: | Vectors | ||
| Affected QGIS version: | master | Regression?: | No |
| Operating System: | Easy fix?: | Yes | |
| Pull Request or Patch supplied: | No | Resolution: | fixed/implemented |
| Crashes QGIS or corrupts data: | No | Copied to github as #: | 25575 |
Description
In QgsVectorLayer::updateFeature, when updating a record that contains 2 geometries, after the record has been created with the first geometry,
the second cannot be updated with a valid geometry since the 'current' returns hasGeometry() == 0.
QgsFeature currentFeature = getFeature( updatedFeature.id() );
if ( currentFeature.isValid() )
{
QgsDebugMsg( QString( "feature %1 could not be retrieved" ).arg( updatedFeature.id() ) );
if ( updatedFeature.hasGeometry() && currentFeature.hasGeometry() && !updatedFeature.geometry().isGeosEqual( currentFeature.geometry() ) )
{
...
}
}
The check for && currentFeature.hasGeometry() should be removed
- updating a NULL geometry with a valid new geometry should be allowed
- this is a leftover from changes made to return when the record could not be retrieved
- this message should occur as the else of the isValid() statement.
QgsFeature currentFeature = getFeature( updatedFeature.id() );
if ( currentFeature.isValid() )
{
QgsDebugMsg( QString( "feature %1 could was retrieved updatedFeature.hasGeometry[%2] currentFeature.hasGeometry[%3]" ).arg( updatedFeature.id() ).arg(updatedFeature.hasGeometry()).arg(currentFeature.hasGeometry()) );
if ( updatedFeature.hasGeometry() && !updatedFeature.geometry().isGeosEqual( currentFeature.geometry() ) )
{
...
}
}
else
{
QgsDebugMsg( QString( "feature %1 could not be retrieved" ).arg( updatedFeature.id() ) );
}
Associated revisions
Fix QgsVectorLayer::updateFeature returns true when errors occur
Refs #17678
Fix QgsVectorLayer::updateFeature cannot add geometry to feature
with no existing geometry
Fixes #17678
History
#1
Updated by Mark Johnson almost 8 years ago
At present when !currentFeature.isValid(), false is not returned
- so a 'return false* is also needed after the message
#2
Updated by Nyall Dawson almost 8 years ago
- % Done changed from 0 to 100
- Status changed from Open to Closed
Applied in changeset qgis|71cdb8cf8e99b249a310cfb359c79d82baccb008.
#3
Updated by Giovanni Manghi over 7 years ago
- Resolution set to fixed/implemented