<div dir="ltr">Also Denis.  You can simplify the code a lot like this:<div><br></div><div style>for f in <span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">vectorLayer.getFeatures( QgsFeatureRequest() ):</span></div>

<div style><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">    f[field] = 1</span></div><div style><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">    </span><span style="color:rgb(0,0,0);font-family:arial,sans-serif;font-size:13px">vectorLayer.updateFeature(f)</span></div>

</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Mar 22, 2013 at 11:10 PM, Denis Rouzaud <span dir="ltr"><<a href="mailto:denis.rouzaud@gmail.com" target="_blank">denis.rouzaud@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    Yes exactly<br>
    <br>
                f = QgsFeature()<br>
                iter = vectorLayer.getFeatures( QgsFeatureRequest() )<br>
                while iter.nextFeature( f ):<br>
                    print <a href="http://f.id" target="_blank">f.id</a>()<br>
                    f.setAttribute( field, QVariant( 1 ) )<br>
                    vectorLayer.updateFeature( f )<br>
    <br>
    Prints only 1 id, commenting the last line prints all ids.<div><div class="h5"><br>
    <br>
    On 03/22/2013 01:56 PM, Nathan Woodrow wrote:<br>
    <blockquote type="cite">
      <div dir="ltr">Do you mean your loop is exited when you call
        updateFeature?
        <div><br>
        </div>
        <div>Can you post your code.</div>
        <div><br>
        </div>
        <div>- Nathan</div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">
          On Fri, Mar 22, 2013 at 10:54 PM, Denis Rouzaud <span dir="ltr"><<a href="mailto:denis.rouzaud@gmail.com" target="_blank">denis.rouzaud@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            Hi all,<br>
            <br>
            I am looping over features of a layer using new API
            (QgsFeatureRequest).<br>
            If I modify a feature and do: layer.updateFeature(f), my
            loop is broken.<br>
            Is this a normal behavior?<br>
            <br>
            What should I do if I want to modify features during the
            loop?<br>
            <br>
            Thanks<br>
            <br>
            Denis<br>
            _______________________________________________<br>
            Qgis-developer mailing list<br>
            <a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
            <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
  </div></div></div>

</blockquote></div><br></div>