[Qgis-developer] QGIS crashes when doing a rollback after modifying values of an user-added feature with pyQGIS

Martin Dobias wonder.sk at gmail.com
Sun Mar 6 00:52:48 PST 2016

Hi Manuel

On Fri, Mar 4, 2016 at 10:05 PM, Manuel Hernández Martínez
<mhernandezm at agenciamedioambienteyagua.es> wrote:
> self.iface.mapCanvas().currentLayer().featureAdded.connect(self._debug_onFeatureAdded)
>     def _debug_onFeatureAdded(self, fid):
>         layer = self.iface.mapCanvas().currentLayer()
>         layer.beginEditCommand("Set UUID")
>         print layer.changeAttributeValue(fid, layer.fieldNameIndex('guid_pol'), 'some_random_uuid') # prints True
>         layer.endEditCommand()
>  [...]
> When I edit the layer, if I add a feature the field 'guid_pol' is set to
> 'some_random_uuid' as expected. I can commit the changes without a problem,
> however if instead of committing the changes I try cancelling them QGIS
> crashes with error 0xC0000005 (Access Violation).

Unfortunately this is currently a limitation of our current editing
system... When an editing signal (like "featureAdded") is emitted,
doing some extra editing actions will corrupt the undo stack because
the undo command of the previous action is not yet finished. A
possible workaround could be to use queued signal/slot connection
instead of direct connection (which is the default), so the slot
execution will be delayed, and the undo stack will get to a consistent


More information about the Qgis-developer mailing list