Skip to content

Commit

Permalink
Fix ticket #5584 (crash saving empty geometry)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Feb 5, 2013
1 parent f47d820 commit 96a8bd6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -566,7 +566,7 @@ void QgsOgrProvider::loadFields()
}

mAttributeFields.append(
QgsField(
QgsField(
//TODO: fix this hack
#ifdef ANDROID
OGR_Fld_GetNameRef( fldDef ),
Expand Down Expand Up @@ -757,13 +757,15 @@ bool QgsOgrProvider::addFeature( QgsFeature& f )
unsigned char* wkb = f.geometry()->asWkb();
OGRGeometryH geom = NULL;

if ( OGR_G_CreateFromWkb( wkb, NULL, &geom, f.geometry()->wkbSize() ) != OGRERR_NONE )
if ( wkb )
{
pushError( tr( "OGR error creating wkb for feature %1: %2" ).arg( f.id() ).arg( CPLGetLastErrorMsg() ) );
return false;
if ( OGR_G_CreateFromWkb( wkb, NULL, &geom, f.geometry()->wkbSize() ) != OGRERR_NONE )
{
pushError( tr( "OGR error creating wkb for feature %1: %2" ).arg( f.id() ).arg( CPLGetLastErrorMsg() ) );
return false;
}
OGR_F_SetGeometryDirectly( feature, geom );
}

OGR_F_SetGeometryDirectly( feature, geom );
}

const QgsAttributes& attrs = f.attributes();
Expand Down

0 comments on commit 96a8bd6

Please sign in to comment.