Opened 13 years ago
Closed 13 years ago
#4073 closed defect (fixed)
[Shapelib - PATCH] DBFAddNativeFieldType should flush the active record before updating the file
Reported by: | Even Rouault | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | OGR_SF | Version: | unspecified |
Severity: | normal | Keywords: | shape CreateField() |
Cc: |
Description
The following snippet leads to junk being written in the first record because it is not flushed to disk before adding the second field. The attached patch fixes this by issuing a DBFFlushRecord() at the beginning of DBFAddNativeFieldType.
ds = ogr.GetDriverByName('ESRI Shapefile').CreateDataSource('createfield.dbf') lyr = ds.CreateLayer('createfield') lyr.CreateField(ogr.FieldDefn('foo', ogr.OFTString)) feat = ogr.Feature(lyr.GetLayerDefn()) feat.SetField(0, 'foo') lyr.CreateFeature(feat) lyr.CreateField(ogr.FieldDefn('bar', ogr.OFTString)) feat = ogr.Feature(lyr.GetLayerDefn()) feat.SetField(1, 'bar') lyr.CreateFeature(feat) ds = None
Attachments (1)
Change History (2)
by , 13 years ago
Attachment: | dbfopen_fix_DBFAddNativeFieldType.patch added |
---|
comment:1 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Patch applied upstream, and pulled back into trunk (r22328).