Skip to content

Commit d915950

Browse files
committedNov 1, 2021
Don't crash when calling applyDashPattern on empty geometries
1 parent b90440b commit d915950

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed
 

‎src/core/geometry/qgsinternalgeometryengine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2920,7 +2920,7 @@ QgsGeometry QgsInternalGeometryEngine::applyDashPattern( const QVector<double> &
29202920
return QgsGeometry( mGeometry->clone() );
29212921

29222922
mLastError.clear();
2923-
if ( !mGeometry )
2923+
if ( !mGeometry || mGeometry->isEmpty() )
29242924
{
29252925
return QgsGeometry();
29262926
}

‎tests/src/python/test_qgsgeometry.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6409,6 +6409,9 @@ def testApplyDashPattern(self):
64096409
"""Test apply dash pattern"""
64106410
self.assertEqual(QgsGeometry.fromWkt('Point (1 1)').applyDashPattern([1, 2]).asWkt(3), 'Point (1 1)')
64116411
self.assertEqual(QgsGeometry.fromWkt('LineString (1 1)').applyDashPattern([1, 2]).asWkt(3), '') # don't crash!
6412+
self.assertEqual(QgsGeometry.fromWkt('LineString EMPTY').applyDashPattern([1, 2]).asWkt(3), '') # don't crash!
6413+
self.assertEqual(QgsGeometry.fromWkt('Polygon EMPTY').applyDashPattern([1, 2]).asWkt(3), '') # don't crash!
6414+
64126415
# bad pattern length
64136416
self.assertEqual(QgsGeometry.fromWkt('LineString (1 1, 10)').applyDashPattern([1, 2, 3]).asWkt(3), '') # don't crash!
64146417
self.assertEqual(QgsGeometry.fromWkt('LineString (1 1, 10 1)').applyDashPattern([1, 2]).asWkt(3),

0 commit comments

Comments
 (0)
Please sign in to comment.