[Qgis-developer] Error/Crash withsimple api command setGeometry

rey sebastien reyman64 at gmail.com
Fri Oct 7 04:11:46 EDT 2011


Hello, a simple question about changing geometry ...

I create a simple point layer, with two point, my simple objective is to 
change the geometry of point 1 by copying the geometry of point 2 into 
geometry of point1.

I select one of my point, and I run this source code into python console :

--

mapC = qgis.utils.iface.mapCanvas()
layer = mapC.currentLayer()
provider = layer.dataProvider()
feat = QgsFeature()
provider.nextFeature(feat)

myGeom = feat.geometry()

while provider.nextFeature(feat):
     layer.startEditing()
     feat.setGeometry(myGeom) #replace the feature geometry by the 
geometry of mygeom
     layer.commitChanges()

--

Qgis crash after that, but i don't understand why ??
Can anyone help me on this function setGeometry ?

Thanks a lot,
Best regards,
SR.


More information about the Qgis-developer mailing list