[Qgis-developer] R: Re: wrapping changeAttributeValue between begin and end EditCommand
francescoboccacci at libero.it
francescoboccacci at libero.it
Mon Mar 16 00:45:11 PDT 2015
Hi Martin,
Thanks for your reply. I try to create a workaround as you suggest me.
Thanks
Francesco
----Messaggio originale----
Da: wonder.sk at gmail.com
Data: 16/03/2015 5.19
A: "francescoboccacci at libero.it"<francescoboccacci at libero.it>
Cc: "qgis-dev"<qgis-developer at lists.osgeo.org>
Ogg: Re: [Qgis-developer] wrapping changeAttributeValue between begin and end EditCommand
Hi Francesco
Currently it is not safe to do calls that modify vector layer data in slots connected to signals notifying about data change (such as featureAdded). The issue is that at the point when those signals are emitted, their underlying undo commands were not yet pushed onto the stack, so doing further editing calls causes corruption of undo stack (undo command for follow up operation is placed before the first operation).
As a workaround you could defer the change attribute operations - e.g. with a QTimer. Not an elegant solution though...
RegardsMartin
On Sun, Mar 15, 2015 at 9:04 PM, francescoboccacci at libero.it <francescoboccacci at libero.it> wrote:
Hi all,
i have a problem with beginEditCommand and endEditCommand wrapping.
In my plugin i capture the layer.featureAdded signal :
self.layer.featureAdded.connect(self.myfunction)
The scope of my function is to change attribute of the feature added according with some rules.
I wrap self.layer.changeAttributevalue between self.layer.beginEditCommand('My custom value') and self.layer.endEditCommand() but when i added a feature i can't see in Undo/redo window the label My custom value but my value is changed.
This cause a Qgis 2.8.2 crash when i try to rollback my changes.
P.S If i comment my change values function and i write the code in a python console i can see my beginEditCommand label and no crash happend.
Anyone can help me?
Thanks
Francesco
_______________________________________________
Qgis-developer mailing list
Qgis-developer at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150316/79644c23/attachment.html>
More information about the Qgis-developer
mailing list