[Qgis-developer] commit change in geometry produce fatal error

Martin Dobias wonder.sk at gmail.com
Thu Feb 12 09:07:13 PST 2015


Hi again Remi

On Thu, Feb 12, 2015 at 11:46 PM, Rémi Cura <remi.cura at gmail.com> wrote:

> Hello again dear list,
>
> Our goal is to save (commitchanges) any modification of a vector layer
> when it happens.
>
>
> We encountered another problem when trying to exploit the
> layer.geometryChanged event.
>
> Upon activation of this event, we tried to use the layer.commitChanges()
> to save changes in geometry of the layer (postgis layer, maybe not
> related),
>
> But it hard-crashes QGIS.
> A quick gdb look seems to indicate a rollback issue??
>

It is not a good idea to try to commit changes in a slot connected to a
signal about layer modification - crashes due to corrupted undo stack can
be expected (the undo stack is not in final state yet at the time of the
signal being emitted). Also often the changes are done in batches (e.g.
field calculator) and if you committed changes after each single change,
this may lead to poor performance due to separate transactions.

I think for your use case you could watch changes to the undo stack and
commit whenever you detect a new undo command is added (e.g.
canUndoChanged() or indexChanged() signal) you could commit the changes.

Regards
Martin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20150213/59f734c5/attachment.html>


More information about the Qgis-developer mailing list