mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
Fix crash in QgsGeometry::unaryUnion with empty geometries
This commit is contained in:
parent
2db7fca7a6
commit
b61641dc72
@ -1618,7 +1618,7 @@ QgsGeometry *QgsGeometry::unaryUnion( const QList<QgsGeometry*> &geometryList )
|
||||
QList<QgsGeometry*>::const_iterator it = geometryList.constBegin();
|
||||
for ( ; it != geometryList.constEnd(); ++it )
|
||||
{
|
||||
if ( *it )
|
||||
if ( *it && !(( *it )->isEmpty() ) )
|
||||
{
|
||||
geomV2List.append(( *it )->geometry() );
|
||||
}
|
||||
|
@ -90,6 +90,8 @@ class TestQgsGeometry : public QObject
|
||||
void bufferCheck();
|
||||
void smoothCheck();
|
||||
|
||||
void unaryUnion();
|
||||
|
||||
void dataStream();
|
||||
|
||||
void exportToGeoJSON();
|
||||
@ -3256,6 +3258,20 @@ void TestQgsGeometry::smoothCheck()
|
||||
QVERIFY( QgsGeometry::compare( multipoly, expectedMultiPoly ) );
|
||||
}
|
||||
|
||||
void TestQgsGeometry::unaryUnion()
|
||||
{
|
||||
//test QgsGeometry::unaryUnion with null geometry
|
||||
QString wkt1 = "Polygon ((0 0, 10 0, 10 10, 0 10, 0 0 ))";
|
||||
QString wkt2 = "Polygon ((2 2, 4 2, 4 4, 2 4, 2 2))";
|
||||
QScopedPointer< QgsGeometry > geom1( QgsGeometry::fromWkt( wkt1 ) );
|
||||
QScopedPointer< QgsGeometry > geom2( QgsGeometry::fromWkt( wkt2 ) );
|
||||
QScopedPointer< QgsGeometry > empty( new QgsGeometry() );
|
||||
QList< QgsGeometry* > list;
|
||||
list << geom1.data() << empty.data() << geom2.data();
|
||||
|
||||
QScopedPointer< QgsGeometry > result( QgsGeometry::unaryUnion( list ) );
|
||||
}
|
||||
|
||||
void TestQgsGeometry::dataStream()
|
||||
{
|
||||
QString wkt = "Point (40 50)";
|
||||
|
Loading…
x
Reference in New Issue
Block a user