Skip to content

Commit

Permalink
Fix crash in test
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Aug 14, 2017
1 parent 0683528 commit cb29b2e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/core/geometry/qgsgeometryeditutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ QgsGeometry::OperationResult QgsGeometryEditUtils::addPart( QgsAbstractGeometry
if ( QgsWkbTypes::flatType( geom->wkbType() ) == QgsWkbTypes::MultiSurface
|| QgsWkbTypes::flatType( geom->wkbType() ) == QgsWkbTypes::MultiPolygon )
{
std::unique_ptr<QgsCurve> curve( qgsgeometry_cast<QgsCurve *>( part.get() ) );
if ( curve )
part.release();
QgsCurve *curve = qgsgeometry_cast<QgsCurve *>( part.get() );

if ( curve && curve->isClosed() && curve->numPoints() >= 4 )
{
Expand All @@ -135,7 +133,10 @@ QgsGeometry::OperationResult QgsGeometryEditUtils::addPart( QgsAbstractGeometry
{
poly.reset( new QgsCurvePolygon() );
}
poly->setExteriorRing( curve.release() );
// Ownership is still with part, curve points to the same object and is transferred
// to poly here.
part.release();
poly->setExteriorRing( curve );
added = geomCollection->addGeometry( poly.release() );
}
else if ( QgsWkbTypes::flatType( part->wkbType() ) == QgsWkbTypes::Polygon )
Expand Down

0 comments on commit cb29b2e

Please sign in to comment.