From 7f3180926d7d3524960bbb56476ad6906ec18195 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Thu, 21 May 2015 18:27:39 +1000 Subject: [PATCH] Followup c6f9b07, add unit test --- tests/src/core/testqgsfeature.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/src/core/testqgsfeature.cpp b/tests/src/core/testqgsfeature.cpp index 60c31ad91bd..96dcd5778da 100644 --- a/tests/src/core/testqgsfeature.cpp +++ b/tests/src/core/testqgsfeature.cpp @@ -221,6 +221,12 @@ void TestQgsFeature::geometry() QVERIFY( ! copy.constGeometry() ); QCOMPARE( *feature.constGeometry()->asWkb(), *mGeometry.data()->asWkb() ); + //test no crash when setting an empty geometry and triggering a detach + QgsFeature emptyGeomFeature; + emptyGeomFeature.setGeometry( 0 ); + copy = emptyGeomFeature; + copy.setFeatureId( 5 ); //force detach + //setGeometry //always start with a copy so that we can test implicit sharing detachment is working copy = feature; @@ -257,14 +263,14 @@ void TestQgsFeature::geometry() QCOMPARE( *feature.constGeometry()->asWkb(), *mGeometry.data()->asWkb() ); //geometryAndOwnership -Q_NOWARN_DEPRECATED_PUSH + Q_NOWARN_DEPRECATED_PUSH copy = feature; QCOMPARE( *copy.constGeometry()->asWkb(), *mGeometry.data()->asWkb() ); QgsGeometry* geom1 = copy.geometryAndOwnership(); QCOMPARE( *geom1->asWkb(), *mGeometry->asWkb() ); QgsGeometry* geom2 = feature.geometryAndOwnership(); QCOMPARE( *geom2->asWkb(), *mGeometry->asWkb() ); -Q_NOWARN_DEPRECATED_POP + Q_NOWARN_DEPRECATED_POP delete geom1; delete geom2; }