Skip to content
Permalink
Browse files
Don't crash when calling applyDashPattern on empty geometries
  • Loading branch information
nyalldawson committed Nov 1, 2021
1 parent b90440b commit d915950707e9cbf49d4dfcc1a61f2ec87db0f2af
Showing with 4 additions and 1 deletion.
  1. +1 −1 src/core/geometry/qgsinternalgeometryengine.cpp
  2. +3 −0 tests/src/python/test_qgsgeometry.py
@@ -2920,7 +2920,7 @@ QgsGeometry QgsInternalGeometryEngine::applyDashPattern( const QVector<double> &
return QgsGeometry( mGeometry->clone() );

mLastError.clear();
if ( !mGeometry )
if ( !mGeometry || mGeometry->isEmpty() )
{
return QgsGeometry();
}
@@ -6409,6 +6409,9 @@ def testApplyDashPattern(self):
"""Test apply dash pattern"""
self.assertEqual(QgsGeometry.fromWkt('Point (1 1)').applyDashPattern([1, 2]).asWkt(3), 'Point (1 1)')
self.assertEqual(QgsGeometry.fromWkt('LineString (1 1)').applyDashPattern([1, 2]).asWkt(3), '') # don't crash!
self.assertEqual(QgsGeometry.fromWkt('LineString EMPTY').applyDashPattern([1, 2]).asWkt(3), '') # don't crash!
self.assertEqual(QgsGeometry.fromWkt('Polygon EMPTY').applyDashPattern([1, 2]).asWkt(3), '') # don't crash!

# bad pattern length
self.assertEqual(QgsGeometry.fromWkt('LineString (1 1, 10)').applyDashPattern([1, 2, 3]).asWkt(3), '') # don't crash!
self.assertEqual(QgsGeometry.fromWkt('LineString (1 1, 10 1)').applyDashPattern([1, 2]).asWkt(3),

0 comments on commit d915950

Please sign in to comment.