[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
Wed May 23 06:28:10 PDT 2012


Thanks Martin
It's working fine now!

On Tue, May 22, 2012 at 8:35 PM, Martin Dobias <wonder.sk at gmail.com> wrote:
> On Mon, May 21, 2012 at 1:26 AM, Ricardo Filipe Soares Garcia da
> <ricardo.garcia.silva at gmail.com> wrote:
>> Hi list
>>
>> I am writing a plugin that creates new features. According to the
>> pyqgis cookbook[0], and the API docs[1], 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?
>
> Ooops, it seems that some documentation is missing! I have just added
> some notes to PyQGIS cookbook, hope that helps:
> https://github.com/qgis/QGIS-Developer-Cookbook/commit/869c9e19af3278f67770895326fb9fbcfeece848
>
>
>> Also, when I press the 'toggle editing' button in the digitizing
>> toolbar, in order to save the changes I am getting a strange
>> behaviour:
>>
>> - 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
>
> That's a check to ensure that the undo stack is working properly - it
> will not crash if you wrap it into the edit commands.
>
> Martin



-- 
___________________________ ___ __
Ricardo Garcia Silva


More information about the Qgis-developer mailing list