Bug report #7772

crash while setting attributes of a new feature

Added by Denis Rouzaud over 11 years ago. Updated over 11 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:-
Category:Vectors
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:16668

Description

The following code crashes at setting the arrtirbute

fields = layer.dataProvider().fields()
f = QgsFeature()
f.setFields(fields)
for field in fields:
    f[field.name()] = QVariant("1")

Using QVariant or not.

Associated revisions

Revision 524e142e
Added by Matthias Kuhn over 11 years ago

[Fix #7772] Check attribute index before setting attribute to avoid crash

History

#1 Updated by Denis Rouzaud over 11 years ago

using initAttributes(fieldCount) after setFields works and prevent the crash.

#2 Updated by Matthias Kuhn over 11 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF