Bug report #6097
Getting wrong attribute values from a feature in qgis
|Affected QGIS version:||1.8.0||Regression?:||No|
|Operating System:||Windows||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||not reproducable|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||15443|
This scenario shows the bug:
I make two polylines features(in my example both consists of two points) with the add feature tool. Then I (with code) add some attribute values on the first feature, then changes the geometry of the second feature before I add values to the second values.
When I use layer.featureAtId() to get the second feature and then reads it, I get the values from the first feature.
But when using feat.geometry().asPolyline(), I get the correct geometry
I don't get this problem if I don't change the geometry or if I commit the two new polylines before doing the mentioned operations.
In the attribute table it is correct. If I use layer.nextFeature(feat) to iterate through all the features I get the right value.
There is a python script attached to show the bug. This code demands a little manual interaction to work. The comments says where the interaction is needed.