[Qgis-developer] Undo command crashes QGIS when called from within plugin.

John Stevenson john.stevenson at thinkwhere.com
Fri Dec 18 04:00:40 PST 2015


Hi,

I have code within a plugin that I am writing that is similar to:

```
def feature_added(self, fid):
    self.vlayer.beginEditCommand('Update attributes')
    self.vlayer.changeAttributeValue(fid, 2, 17)
    self.vlayer.endEditCommand()
```

It is called in response to a featureAdded signal from the layer.  The command runs and the attributes are updated and the canvas refreshes to show them.  However, when I check the undoStack for the layer, the command is not present.  When I press 'Undo', QGIS has a hard crash.

If I use the QGIS iPython console to access the layer directly through my plugin (e.g. via qgis.utils.plugins['MyPlugin']) and type the equivalent commands directly into the console, everything works as expected, but the changes are not visible until the canvas is manually refreshed.

Is there something else that should / shouldn't be called by the plugin to put the undo command onto the stack?

I'm on QGIS 2.12.0 on Linux Mint 17 (Ubuntu 14.04).

Thanks,
John



John Stevenson
Senior Developer


[cid:image6f2e87.PNG at 5b109e70.4c82a5fd]<http://www.thinkwhere.com>


t: 01786 476060 (Office)
t: 01786 476093 (Direct Dial)
w:www.thinkwhere.com<http://www.thinkwhere.com>


Glendevon House
Castle Business Park
Stirling FK9 4TZ


[cid:image93fee1.PNG at 76e49b2d.499be68b]<https://twitter.com/thinkWhere1> [cid:imageaf7fc7.PNG at e09bbbf0.4392c48d] <http://www.linkedin.com/company/1509510?trk=companies_home_ycp_logo_forth-valley-gis>


This email and its attachments are private and confidential. If you believe you have received this email in error, please contact the sender immediately on 01786 476060. If you are not the intended recipient, you may not rely on, use or disclose this email or any attachments in any way.

thinkWhere Limited does not accept any liability for any damage that may be caused to the recipient's system or data by this email or any attachments. Please note that our email system may be subject to random monitoring by us. This Company accepts no liability for personal emails.

thinkWhere is a limited company registered in Scotland with Registered Number SC315349 and having its Registered Office at Glendevon House, Castle Business Park, Stirling, FK9 4TZ.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20151218/06222ea9/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image6f2e87.PNG
Type: image/png
Size: 7004 bytes
Desc: image6f2e87.PNG
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20151218/06222ea9/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image93fee1.PNG
Type: image/png
Size: 3618 bytes
Desc: image93fee1.PNG
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20151218/06222ea9/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: imageaf7fc7.PNG
Type: image/png
Size: 3751 bytes
Desc: imageaf7fc7.PNG
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20151218/06222ea9/attachment-0005.png>


More information about the Qgis-developer mailing list