Skip to content
Permalink
Browse files

Fix some memory leaks

  • Loading branch information
nyalldawson committed Aug 25, 2015
1 parent 039b4fb commit a954c3f2bb75b0de63aaa1c24e1d09c06ca3ed50
Showing with 18 additions and 4 deletions.
  1. +7 −0 src/core/geometry/qgsgeometry.cpp
  2. +8 −4 tests/src/core/testqgsexpression.cpp
  3. +3 −0 tests/src/core/testqgsgeometry.cpp
@@ -146,6 +146,13 @@ const QgsAbstractGeometryV2* QgsGeometry::geometry() const
void QgsGeometry::setGeometry( QgsAbstractGeometryV2* geometry )
{
detach( false );
if ( d->geometry )
{
delete d->geometry;
d->geometry = 0;
}
removeWkbGeos();

d->geometry = geometry;
}

@@ -1007,10 +1007,14 @@ class TestQgsExpression: public QObject
QgsPolygon polygon;
polygon << polygon_ring;

QTest::newRow( "geomFromWKT Point" ) << "geom_from_wkt('" + QgsGeometry::fromPoint( point )->exportToWkt() + "')" << ( void* ) QgsGeometry::fromPoint( point ) << false;
QTest::newRow( "geomFromWKT Line" ) << "geomFromWKT('" + QgsGeometry::fromPolyline( line )->exportToWkt() + "')" << ( void* ) QgsGeometry::fromPolyline( line ) << false;
QTest::newRow( "geomFromWKT Polyline" ) << "geomFromWKT('" + QgsGeometry::fromPolyline( polyline )->exportToWkt() + "')" << ( void* ) QgsGeometry::fromPolyline( polyline ) << false;
QTest::newRow( "geomFromWKT Polygon" ) << "geomFromWKT('" + QgsGeometry::fromPolygon( polygon )->exportToWkt() + "')" << ( void* ) QgsGeometry::fromPolygon( polygon ) << false;
QScopedPointer<QgsGeometry> sourcePoint( QgsGeometry::fromPoint( point ) );
QTest::newRow( "geomFromWKT Point" ) << "geom_from_wkt('" + sourcePoint->exportToWkt() + "')" << ( void* ) QgsGeometry::fromPoint( point ) << false;
QScopedPointer<QgsGeometry> sourceLine( QgsGeometry::fromPolyline( line ) );
QTest::newRow( "geomFromWKT Line" ) << "geomFromWKT('" + sourceLine->exportToWkt() + "')" << ( void* ) QgsGeometry::fromPolyline( line ) << false;
QScopedPointer<QgsGeometry> sourcePolyline( QgsGeometry::fromPolyline( polyline ) );
QTest::newRow( "geomFromWKT Polyline" ) << "geomFromWKT('" + sourcePolyline->exportToWkt() + "')" << ( void* ) QgsGeometry::fromPolyline( polyline ) << false;
QScopedPointer<QgsGeometry> sourcePolygon( QgsGeometry::fromPolygon( polygon ) );
QTest::newRow( "geomFromWKT Polygon" ) << "geomFromWKT('" + sourcePolygon->exportToWkt() + "')" << ( void* ) QgsGeometry::fromPolygon( polygon ) << false;

// GML Point
QTest::newRow( "GML Point (coordinates)" ) << "geomFromGML('<gml:Point><gml:coordinates>123,456</gml:coordinates></gml:Point>')" << ( void * ) QgsGeometry::fromPoint( point ) << false;
@@ -211,6 +211,7 @@ void TestQgsGeometry::cleanup()
delete mpPolygonGeometryA;
delete mpPolygonGeometryB;
delete mpPolygonGeometryC;
delete mpPolylineGeometryD;
delete mpPainter;
}

@@ -456,6 +457,8 @@ void TestQgsGeometry::initTestCase()

void TestQgsGeometry::cleanupTestCase()
{


//
// Runs once after all tests are run
//

0 comments on commit a954c3f

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