Bug report #10216

can't set empty geometry with QgsVectorDataProvider::changeGeometryValues(QgsGeometryMap&)

Added by Luigi Pirelli over 10 years ago. Updated over 10 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Data Provider
Affected QGIS version:2.2.0 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:18662

Description

I discovered the problem trying to set value using python binding using Spatialite provider. I didn't test on postgis.

First case:
layer.dataProvider().changeGeometryValues( {index:None} )
generate a misleading exception on changeGeometryValues dict parameter

Second case i followed suggestion to use:
layer.dataProvider().changeGeometryValues( {index:QgsGeometry()} )
generate no error, but no modification on the layer feature geometry

thi is due to a control in qgsspatialiteprovider.cpp:3985

if ( iter->asWkb() )

if it is QgsGeometry() => asWkb() return (correctly) 0 and the geometry is skipped... and changeGeometryValues(...) return true!

I don't know if changing this behavior can affect other places

if it's a bug, probably should be backported to 2.2

History

#1 Updated by Luigi Pirelli over 10 years ago

testing first case:
1) get a spatialite layer and select it (geometry constraing have to allow empty geometry or NULL value)
2) from python console
vl=iface.activeLayer()
vl.dataProvider().changeGeometryValues( {3L:None} ) <- in this case 3L is a valid index
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: QgsVectorDataProvider.changeGeometryValues(dict-of-qint64-QgsGeometry): argument 1 has unexpected type 'dict'

tetting second case:
1) get a spatialite layer and select it
2) from python console
vl=iface.activeLayer()
vl.dataProvider().changeGeometryValues( {3L:QgsGeometry()} ) <- in this case 3L is a valid index
True
3) check that geometry is not changed (refreshing canvas or checking in DB)
4) check that it works using geometry different from None or QgsGeometry()

#2 Updated by Luigi Pirelli over 10 years ago

First type error

TypeError: QgsVectorDataProvider.changeGeometryValues(dict-of-qint64-QgsGeometry): argument 1 has unexpected type 'dict'

I think is originated by SIP wrapper because call doesn't arrive to c++ changeGeometryValues method.

I'll try to write a patch only for the case 2

#3 Updated by Luigi Pirelli over 10 years ago

I can confirm bug also pro Postgres provider

#4 Updated by Luigi Pirelli over 10 years ago

  • Status changed from Open to Closed

closed with commit 38e694713a742baa85577c6454934d0ca43a7f66 thanks to Jürgen fisher for some modification of the pull request: https://github.com/qgis/QGIS/pull/1343

Also available in: Atom PDF