[Qgis-developer] Adding features with an editing buffer - undo
action unavailable in the GUI?
Ricardo Filipe Soares Garcia da
ricardo.garcia.silva at gmail.com
Sun May 20 16:26:32 PDT 2012
I am writing a plugin that creates new features. According to the
pyqgis cookbook, and the API docs, when I call the addFeatures
method on a QgsVectorLayer, the features should get added to the
layers editing buffer. It is my understanding that this action ought
to be undo-able, since the changes haven't been commited yet. But the
undo icon in the QGIS GUI doesn't seem to be aware of the changes that
the plugin is making to the layer. Do I have to hook up the changes to
the undo/redo stack myself? How can I do this?
The code is available on github, and here is an excerpt:
layer = self.canvas.currentLayer()
point = self.calculate_point() # returns a QgsPoint
f = qgis.core.QgsFeature()
geom = qgis.core.QgsGeometry.fromPoint(point)
Please note that the new feature is being created successfully. I just
want the user to have the ability to undo the feature creation.
Also, when I press the 'toggle editing' button in the digitizing
toolbar, in order to save the changes I am getting a strange
- If I choose to save my changes, everything goes fine,
- If I choose to close without saving, QGIS crashes with:
Fatal: ASSERT: "mAddedFeatures.isEmpty()" in file
/home/ricardo/dev/Quantum-GIS/src/core/qgsvectorlayer.cpp, line 3982
and a lot more output in the stacktrace.
Thanks for you help!
 - http://www.qgis.org/pyqgis-cookbook/vector.html#modifying-vector-layers-with-an-editing-buffer
 - http://qgis.org/api/classQgsVectorLayer.html#a9936fbfbd69efc6583062e16c6c219ed
 - https://github.com/ricardogsilva/geomtools
___________________________ ___ __
Ricardo Garcia Silva
More information about the Qgis-developer