@@ -259,8 +259,8 @@ static GEOSCoordSequence *createGeosCoordSequence( const QgsPolyline& points )
259
259
catch ( GEOSException &e )
260
260
{
261
261
Q_UNUSED ( e );
262
- if ( coord )
263
- GEOSCoordSeq_destroy ( coord );
262
+ /* if ( coord )
263
+ GEOSCoordSeq_destroy( coord );*/
264
264
throw ;
265
265
}
266
266
}
@@ -335,8 +335,9 @@ static GEOSGeometry *createGeosLinearRing( const QgsPolyline& polyline )
335
335
catch ( GEOSException &e )
336
336
{
337
337
Q_UNUSED ( e );
338
+ /* as MH has noticed ^, this crashes geos
338
339
if ( coord )
339
- GEOSCoordSeq_destroy ( coord );
340
+ GEOSCoordSeq_destroy( coord );*/
340
341
return 0 ;
341
342
}
342
343
}
@@ -2349,7 +2350,8 @@ double QgsGeometry::closestVertexWithContext( const QgsPoint& point, int& atVert
2349
2350
int closestVertexIndex = 0 ;
2350
2351
2351
2352
// set up the GEOS geometry
2352
- exportWkbToGeos ();
2353
+ if ( !exportWkbToGeos () )
2354
+ return -1 ;
2353
2355
2354
2356
const GEOSGeometry *g = GEOSGetExteriorRing ( mGeos );
2355
2357
if ( g == NULL )
@@ -2628,7 +2630,8 @@ int QgsGeometry::addRing( const QList<QgsPoint>& ring )
2628
2630
2629
2631
// create geos geometry from wkb if not already there
2630
2632
if ( !mGeos || mDirtyGeos )
2631
- exportWkbToGeos ();
2633
+ if ( !exportWkbToGeos () )
2634
+ return 6 ;
2632
2635
2633
2636
int type = GEOSGeomTypeId ( mGeos );
2634
2637
@@ -2831,7 +2834,8 @@ int QgsGeometry::addIsland( const QList<QgsPoint>& ring )
2831
2834
// create geos geometry from wkb if not already there
2832
2835
if ( !mGeos || mDirtyGeos )
2833
2836
{
2834
- exportWkbToGeos ();
2837
+ if ( !exportWkbToGeos () )
2838
+ return 4 ;
2835
2839
}
2836
2840
2837
2841
if ( GEOSGeomTypeId ( mGeos ) != GEOS_MULTIPOLYGON )
@@ -3164,7 +3168,8 @@ int QgsGeometry::splitGeometry( const QList<QgsPoint>& splitLine, QList<QgsGeome
3164
3168
}
3165
3169
if ( !mGeos || mDirtyGeos )
3166
3170
{
3167
- exportWkbToGeos ();
3171
+ if ( !exportWkbToGeos () )
3172
+ return 1 ;
3168
3173
}
3169
3174
3170
3175
// make sure splitLine is valid
@@ -3917,6 +3922,7 @@ bool QgsGeometry::exportWkbToGeos()
3917
3922
mGeos = 0 ;
3918
3923
}
3919
3924
3925
+ // this probably shouldn't return TRUE
3920
3926
if ( !mGeometry )
3921
3927
{
3922
3928
// no WKB => no GEOS
@@ -4768,7 +4774,8 @@ int QgsGeometry::splitLinearGeometry( GEOSGeometry *splitLine, QList<QgsGeometry
4768
4774
4769
4775
if ( !mGeos || mDirtyGeos )
4770
4776
{
4771
- exportWkbToGeos ();
4777
+ if ( !exportWkbToGeos () )
4778
+ return 5 ;
4772
4779
}
4773
4780
4774
4781
// first test if linestring intersects geometry. If not, return straight away
@@ -4844,7 +4851,8 @@ int QgsGeometry::splitPolygonGeometry( GEOSGeometry* splitLine, QList<QgsGeometr
4844
4851
4845
4852
if ( !mGeos || mDirtyGeos )
4846
4853
{
4847
- exportWkbToGeos ();
4854
+ if ( !exportWkbToGeos () )
4855
+ return 5 ;
4848
4856
}
4849
4857
4850
4858
// first test if linestring intersects geometry. If not, return straight away
@@ -5062,7 +5070,8 @@ int QgsGeometry::mergeGeometriesMultiTypeSplit( QVector<GEOSGeometry*>& splitRes
5062
5070
{
5063
5071
if ( !mGeos || mDirtyGeos )
5064
5072
{
5065
- exportWkbToGeos ();
5073
+ if ( !exportWkbToGeos () )
5074
+ return 1 ;
5066
5075
}
5067
5076
5068
5077
// convert mGeos to geometry collection
@@ -5328,6 +5337,9 @@ double QgsGeometry::distance( QgsGeometry& geom )
5328
5337
geom.exportWkbToGeos ();
5329
5338
}
5330
5339
5340
+ if ( mGeos == NULL || geom.mGeos == NULL )
5341
+ return -1.0 ;
5342
+
5331
5343
double dist = -1.0 ;
5332
5344
5333
5345
try
0 commit comments