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 Version 2
Reported by: | Owned by: | Mateusz Łoskot | |
---|---|---|---|
Priority: | normal | Milestone: | 1.4.2 |
Component: | OGR_SF | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: | warmerdam |
Description (last modified by )
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
//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
Marco
Change History (2)
comment:1 by , 17 years ago
Cc: | added |
---|---|
Description: | modified (diff) |
Milestone: | → 1.4.2 |
Owner: | changed from | to
Priority: | high → normal |
comment:2 by , 17 years ago
Description: | modified (diff) |
---|
Mateusz,
I'd like you to try to reproduce this problem and see if it still exists. If so, lets fix it. If the fix is straight forward it can go into 1.4.2. If it seems tricky, perhaps just trunk.