Skip to content
Permalink
Browse files

Fix crash in sip tests by storing a reference to geom

  • Loading branch information
elpaso authored and nyalldawson committed Sep 14, 2018
1 parent 08f79be commit aa812356dc33eea5525d122a8027144951c9bd26
Showing with 29 additions and 4 deletions.
  1. +29 −4 tests/src/python/test_qgsprocessinginplace.py
@@ -259,16 +259,20 @@ def test_make_features_compatible(self):
old_feature.setAttributes([1])
old_feature.setGeometry(QgsGeometry.fromWkt('Polygon z ((1 1 1, 2 2 2, 3 3 3 , 1 1 1))'))
l, f = self._make_compatible_tester('Polygon ((1 1, 2 2, 3 3, 1 1))', 'PolygonZ', old_feature=old_feature)
g = f.geometry().get()
print(g)
self.assertEqual(f.geometry().get().z(), 0)
g = f.geometry()
g2 = g.get()
for v in g2.vertices():
self.assertEqual(v.z(), 0)

# Adding M back
old_feature = QgsFeature(self.vl.fields())
old_feature.setAttributes([1])
old_feature.setGeometry(QgsGeometry.fromWkt('Polygon m ((1 1 1, 2 2 2, 3 3 3 , 1 1 1))'))
l, f = self._make_compatible_tester('Polygon ((1 1, 2 2, 3 3, 1 1))', 'PolygonM', old_feature=old_feature)
self.assertEqual(f.geometry().get().m(), 0)
g = f.geometry()
g2 = g.get()
for v in g2.vertices():
self.assertEqual(v.m(), 0)

self._make_compatible_tester('Polygon m ((1 1 1, 2 2 2, 3 3 3, 1 1 1))', 'Polygon')
self._make_compatible_tester('Polygon m ((1 1 1, 2 2 2, 3 3 3, 1 1 1))', 'PolygonM')
@@ -281,6 +285,27 @@ def test_make_features_compatible(self):
self._make_compatible_tester('LineString z ((1 1 1, 2 2 2, 3 3 3, 1 1 1))', 'LineStringZ')
self._make_compatible_tester('LineString m ((1 1 1, 2 2 2, 3 3 3, 1 1 1))', 'LineString')
self._make_compatible_tester('LineString m ((1 1 1, 2 2 2, 3 3 3, 1 1 1))', 'LineStringM')

# Adding Z back
old_feature = QgsFeature(self.vl.fields())
old_feature.setAttributes([1])
old_feature.setGeometry(QgsGeometry.fromWkt('LineString z ((1 1 1, 2 2 2, 3 3 3 , 1 1 1))'))
l, f = self._make_compatible_tester('LineString ((1 1, 2 2, 3 3, 1 1))', 'LineStringZ', old_feature=old_feature)
g = f.geometry()
g2 = g.get()
for v in g2.vertices():
self.assertEqual(v.z(), 0)

# Adding M back
old_feature = QgsFeature(self.vl.fields())
old_feature.setAttributes([1])
old_feature.setGeometry(QgsGeometry.fromWkt('LineString m ((1 1 1, 2 2 2, 3 3 3 , 1 1 1))'))
l, f = self._make_compatible_tester('LineString ((1 1, 2 2, 3 3, 1 1))', 'LineStringM', old_feature=old_feature)
g = f.geometry()
g2 = g.get()
for v in g2.vertices():
self.assertEqual(v.m(), 0)

self._make_compatible_tester('LineString((1 1, 2 2, 3 3, 1 1))', 'MultiLineString')
self._make_compatible_tester('MultiLineString(((1 1, 2 2, 3 3, 1 1)), ((1 1, 2 2, 3 3, 1 1)))', 'MultiLineString')

0 comments on commit aa81235

Please sign in to comment.
You can’t perform that action at this time.