Opened 20 years ago
Last modified 17 years ago
#641 closed defect
crash when creating an empty shapefile and insert a new feature into it — at Initial Version
Reported by: | Owned by: | warmerdam | |
---|---|---|---|
Priority: | normal | Milestone: | 1.4.2 |
Component: | OGR_SF | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: | warmerdam |
Description
Hi, I'm not sure if this is a bug in OGR or in my program. What i try to do is to create an empty shapefile and later to open this shapefile and insert features into it. When i try to add the feature, a crash happens. Also i noticed that a field, which i created on the empty shapefile is not recognised when the empty layer is opened. Below is my source code and the debugger backtrace after the crash. A .tgz of the created files (.shp,.dbf,etc.) befor adding a feature is on ftp://ftp.geo.unizh.ch/pub/mhugent/newlayertest.tgz thanks, Marco //create an empty layer and add a field to it OGRwkbGeometryType geomtype=(OGRwkbGeometryType)((int)vectortype); QString mOutputFormat = "ESRI Shapefile"; QString mOutputFileName = uri; #ifdef WIN32 QString outname=mOutputFileName.mid(mOutputFileName.findRev("\\")+1,mOutputFileName.length()); #else QString outname=mOutputFileName.mid(mOutputFileName.findRev("/")+1,mOutputFileName.length()); #endif OGRSFDriverRegistrar* driverregist = OGRSFDriverRegistrar::GetRegistrar(); if(driverregist==0) { return false; } OGRSFDriver* driver = driverregist->GetDriverByName(mOutputFormat); if(driver==0) { return false; } OGRDataSource* datasource = driver->CreateDataSource(mOutputFileName,NULL); if(datasource==0) { return false; } OGRSpatialReference reference; OGRLayer* layer = datasource->CreateLayer(outname.latin1 (),&reference,geomtype,NULL); if(layer==0) { return false; } OGRFieldDefn fielddef("dummy",OFTReal); fielddef.SetWidth(1); fielddef.SetPrecision(1); if(layer->CreateField(&fielddef,FALSE)!=OGRERR_NONE) { return false; } the debugger output when inserting a new feature afterwards: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 1091298272 (LWP 25403)] 0x40a70218 in DBFGetRecordCount () from /usr/local/lib/libgdal.so.1 (gdb) backtrace #0 0x40a70218 in DBFGetRecordCount () from /usr/local/lib/libgdal.so.1 #1 0x40b0992f in SHPWriteOGRFeature () from /usr/local/lib/libgdal.so.1 #2 0x40af4936 in OGRShapeLayer::CreateFeature () from /usr/local/lib/libgdal.so.1 #3 0x41923027 in QgsShapeFileProvider::commitFeature (this=0x85a0668, f=0x85f7cb0) at qgsshapefileprovider.cpp:820 #4 0x41922e14 in QgsShapeFileProvider::commitChanges (this=Variable "this" is not available. ) at stl_list.h:167
Note:
See TracTickets
for help on using tickets.