Hi,

ok I found what was going on. The issue is the call to ogr2ogr which calls
ogr.RegisterAll(). The effect of calling ogr.RegisterAll() when it has already
been called is to reload the drivers, which will invalidate any opened
datasource, like the one you use indirectly for the source layers. This
datasource then references a destroyed driver, and the crash is just the direct
consequence of that.

So the fix is to replace ogr.RegisterAll() by

        if( ogr.GetDriverCount() == 0 )
            ogr.RegisterAll();

in ogrinfo.java and ogr2ogr.java. Just pushed to SVN trunk.

Otherwise, using ogrinfo.java for the use you make of it is really
over-complicated. Just use :

         if( ogr.GetDriverCount() == 0 )
              ogr.RegisterAll();
         DataSource poDS = ogr.Open(src, false);
         List<Layer> layers = new ArrayList<Layer>();
         for(int i=0;i<poDS.GetLayerCount();i++)
            layers.add(poDS.GetLayer(i));

Best regards,

Even

_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to