Skip to content

Commit

Permalink
fix crash adding features without geometry to a geometry layer
Browse files Browse the repository at this point in the history
  • Loading branch information
brushtyler committed Oct 18, 2012
1 parent faf46b6 commit bb31a2d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2368,6 +2368,12 @@ bool QgsPostgresProvider::changeAttributeValues( const QgsChangedAttributesMap &

void QgsPostgresProvider::appendGeomParam( QgsGeometry *geom, QStringList &params ) const
{
if ( !geom )
{
params << QString::null;
return;
}

QString param;
unsigned char *buf = geom->asWkb();
for ( uint i = 0; i < geom->wkbSize(); ++i )
Expand Down
21 changes: 14 additions & 7 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3674,15 +3674,22 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
if ( !mGeometryColumn.isNull() )
{
// binding GEOMETRY to Prepared Statement
unsigned char *wkb = NULL;
size_t wkb_size;
convertFromGeosWKB( features->geometry()->asWkb(),
features->geometry()->wkbSize(),
&wkb, &wkb_size, nDims );
if ( !wkb )
if ( !features->geometry() )
{
sqlite3_bind_null( stmt, ++ia );
}
else
sqlite3_bind_blob( stmt, ++ia, wkb, wkb_size, free );
{
unsigned char *wkb = NULL;
size_t wkb_size;
convertFromGeosWKB( features->geometry()->asWkb(),
features->geometry()->wkbSize(),
&wkb, &wkb_size, nDims );
if ( !wkb )
sqlite3_bind_null( stmt, ++ia );
else
sqlite3_bind_blob( stmt, ++ia, wkb, wkb_size, free );
}
}

for ( QgsAttributeMap::const_iterator it = attributevec.begin(); it != attributevec.end(); it++ )
Expand Down

0 comments on commit bb31a2d

Please sign in to comment.