Skip to content

Commit

Permalink
Fix crash when preparing/buffering a polygon fails prior to tessellation
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Aug 26, 2023
1 parent 2cdd146 commit 4d464e8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/core/qgssggeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,11 @@ QSGGeometry *QgsSGGeometry::qgsPolygonToQSGGeometry( const QgsPolygon *polygon,
QgsGeometry geom( polygon->clone() );
geom = geom.buffer( 0.0000001, 5 );
QgsPolygon *bufferedPolygon = qgsgeometry_cast<QgsPolygon *>( geom.constGet() );

QgsTessellator t( visibleExtent.xMinimum(), visibleExtent.yMaximum(), false, false, false, true );
t.addPolygon( *bufferedPolygon, 0 );
if ( bufferedPolygon )
{
t.addPolygon( *bufferedPolygon, 0 );
}

QSGGeometry *sgGeom = new QSGGeometry( QSGGeometry::defaultAttributes_Point2D(), t.dataVerticesCount() );

Expand Down
2 changes: 1 addition & 1 deletion src/core/sgrubberband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ QSGGeometryNode *SGRubberband::createPolygonGeometry( const QVector<QgsPoint> &p
geom = geom.buffer( 0.0000001, 5 );
QgsPolygon *polygon = qgsgeometry_cast<QgsPolygon *>( geom.constGet() );
QgsTessellator t( 0, 0, false, false, false, true );
if ( points.size() > 2 )
if ( points.size() > 2 && polygon )
{
t.addPolygon( *polygon, 0 );
}
Expand Down

1 comment on commit 4d464e8

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.