[Gdal-dev] OGR DXF export crashes

Joerg Schwerdt jschwerdt at swbb.de
Fri Oct 6 02:54:08 EDT 2006


I want to export some objects using OGR DXF export.  A function (see below)
is doing this job.
The function is implemented in Delphi and uses der C interface to OGR.

Everything works fine the first time I call this function.  The second (or
third) time this function 
is called the "OGR_Dr_CreateDataSource" command crashes.  (Every call of the
function uses a 
newly created empty directory.)  After restarting my program I can call the
function again once 
(or sometimes twice) without a crash and on the next call it crashes again.

Is there something missing in my function?  May be some things are not freed

The error message of my (german) Delphi is the following:
"Zugriffsverletzung bei Adresse 02F8925F in Modul 'DD_Root.dll'. Lesen von
Adresse 00040014."
This means "access violation on address 02F8925F in modul 'DD_Root.dll'.
reading address 00040014."

Thanks a lot,

J?rg Schwerdt

The mentioned function:

procedure ExportDXF;
  hDriver: OGRSFDriverH;
  SL: tStringList;
  ptrMain: pointer;
  datasource: OGRDataSourceH;
  DateTimeStamp: string;
  APath: DLLString;
  Target: string;
  layerDefn: OGRFeatureDefnH;
  feature: OGRFeatureH;
  geometry: OGRGeometryH;
  hOGRLayer: OGRLayerH;
  hDriver := OGRGetDriverByName('DXF');

  DateTimeStamp := FormatDateTime('yyyymmdd_hhnnss', Now);
  Target := IncludeTrailingPathDelimiter(APath) + 'ShapeExport_AllVisible_'+
DateTimeStamp + '\DXF\export.dxf';

  SL := TStringList.Create;
  ptrMain := OGR_JS_SLToCStringArray(SL);
  datasource := OGR_Dr_CreateDataSource(hDriver, PChar(Target), ptrMain);

  if (datasource<>nil) then begin
    hOGRLayer := OGR_DS_CreateLayer(datasource, pchar('Test_js'), nil,
wkbLineString, nil);
    layerDefn := OGR_L_GetLayerDefn(hOGRLayer);

    // Create a new polyline
    feature := OGR_F_Create(layerDefn);
    geometry := OGR_G_CreateGeometry(wkbLineString);
    OGR_G_AddPoint(geometry, 10.0, 20.0, 10.0);
    OGR_G_AddPoint(geometry, 20.0, 10.0, 10.0);
    OGR_G_AddPoint(geometry, 30.0, 20.0, 10.0);
    OGR_F_SetGeometryDirectly(feature, geometry);
    OGR_L_CreateFeature(hOGRLayer, feature);

  end; {endif}

View this message in context: http://www.nabble.com/OGR-DXF-export-crashes-tf2393756.html#a6674131
Sent from the GDAL - Dev mailing list archive at Nabble.com.

More information about the Gdal-dev mailing list