Jurgen,

What is the purpose of doing all the extra feature lookup in updateFeature?
Just so that don't change all the attributes everytime? I doubt there would
be that much overhead to really care, I would even say the getFeature
request would be slower then just changing all the attributes each time.
 To me this method is broken an shouldn't call getFeatures.  The method is
just updateFeature it shouldn't do anything more, especially not change my
iterator .  If we want to implement attribute change tracking it should be
done on the QgsFeature, which would be easy, not in QgsVectorLayer.

You could then just do (in updateFeature) (in python):

attributes = f.getChangedAttributes()

for index, value in attributes.iteritems():
    layer.changeAttributeValue(id, index, value)

- Nathan



On Sat, Mar 23, 2013 at 1:21 AM, Jürgen E. <j...@norbit.de> wrote:

> Hi Nathan,
>
> On Sat, 23. Mar 2013 at 00:29:03 +1000, Nathan Woodrow wrote:
> > If updateFeature is indeed doing feature request inside and breaking the
> loop
> > then that is a bug.  updateFeature should not affect the feature
>
> The misfeature is that there can only be one active iterator per provider
> (see
> also [1]).  So the feature iterator in updateFeature closes the iterator
> of the
> loop.
>
> > What should I do if I want to modify features during the loop?
>
> replacing
>
> >                      f.setAttribute( field, QVariant( 1 ) )
> >                      vectorLayer.updateFeature( f )
>
> with
>
>                        vectorLayer.changeAttributeValue( f.id(), field, 1
> )
>
> should help.
>
>
> Jürgen
>
> [1] http://hub.qgis.org/issues/7071#note-6
>
> --
> Jürgen E. Fischer         norBIT GmbH               Tel. +49-4931-918175-31
> Dipl.-Inf. (FH)           Rheinstraße 13            Fax. +49-4931-918175-50
> Software Engineer         D-26506 Norden
> http://www.norbit.de
> committ(ed|ing) to Quantum GIS                         IRC: jef on FreeNode
>
> --
> norBIT Gesellschaft fuer Unternehmensberatung und Informationssysteme mbH
> Rheinstrasse 13, 26506 Norden
> GF: Jelto Buurman, HR: Amtsgericht Emden, HRB 5502
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to