[Qgis-developer] qgsAffine bugfix?

Martin Dobias wonder.sk at gmail.com
Mon Dec 8 13:05:36 EST 2008


Hi

On Sun, Dec 7, 2008 at 2:38 AM, vatto <mauricio.dev at gmail.com> wrote:
> Hi everyone,
> I've made an attempt to fix the bug with the extents. I changed the provider's
> update to the vector layer update using :
>
> QgsVectorLayer.startEditing()
> QgsVectorLayer.moveVertex()
> QgsVectorLayer.commitChanges()
>
> The problem is: startEditing() isn't working well from my script. But it works
> from the console. Now the user has to start editing by his own before
> applying the affine transformation.

What does it mean that startEditing() isn't working?


> I think qgis still thinks the geometries are unchanged for extents purpose,
> but when I reopen the file it looks ok. I think I've ran into this kind of
> bug when editing too, so I don't know if it's my script's mistake or QGis'.
> I've been able to reproduce it by editing any polygon in a newly created
> layer. It's always with the wrong extent.

Sorry I didn't get when does this happen... you mean that extent is
not updated after calls to moveVertex() ?


> I've found a bug that when I call commitChanges(): the "Toggle Editing" button
> looks like it's stiil editing, but it's not. I have to click the button again
> and it starts working fine.

This is because QGIS user interface doesn't get updated automatically
(although it probably should). I think you can work this around by
setting a new connection:
QObject.connect( ??, SIGNAL("editingChanged(QgsMapLayer*)"),
iface.mainWindow(), SLOT("activateDeactivateLayerRelatedActions(
QgsMapLayer*)"))
Replace the questionmarks with your own class where you're going to
emit that editingChanged signal. It will look like this:
layer.commitChanges()
self.emit(SIGNAL("editingChanged(QgsMapLayer*)"), layer)

I have not tried the code so probably it's not a copy/paste example.
The important thing is that you want call that
"activateDeactivateLayerRelatedActions" slot of QgisApp that takes
care of updating UI if the layer is active.


> Are these new bugs or am I running into known issues? I can probably reproduce
> the commitChanges() bug in a smaller script.

Probably you're just touching less explored things in QGIS API that
has been used by QGIS application only, so probably the semantics of
some functions isn't like what you would expect...

Martin


More information about the Qgis-developer mailing list