Skip to content

Commit

Permalink
Be super cautious and just log errors when pal obstacle geometry is null
Browse files Browse the repository at this point in the history
(cherry picked from commit cfe335c)
  • Loading branch information
nyalldawson committed Jun 3, 2020
1 parent a22635b commit 724f84d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/pal/layer.cpp
Expand Up @@ -35,6 +35,7 @@
#include "geomfunction.h"
#include "util.h"
#include "qgslabelingengine.h"
#include "qgslogger.h"

#include <cmath>
#include <vector>
Expand Down Expand Up @@ -212,9 +213,17 @@ bool Layer::registerFeature( QgsLabelFeature *lf )
{
const GEOSGeometry *geom = simpleGeometries->takeFirst();

if ( !geom )
{
QgsDebugMsg( QStringLiteral( "Obstacle geometry passed to PAL labeling engine could not be converted to GEOS! %1" ).arg( ( *it )->asWkt() ) );
continue;
}

// ignore invalid geometries (e.g. polygons with self-intersecting rings)
if ( GEOSisValid_r( geosctxt, geom ) != 1 ) // 0=invalid, 1=valid, 2=exception
{
// this shouldn't happen -- we have already checked this while registering the feature
QgsDebugMsg( QStringLiteral( "Obstacle geometry passed to PAL labeling engine is not valid! %1" ).arg( ( *it )->asWkt() ) );
continue;
}

Expand Down

0 comments on commit 724f84d

Please sign in to comment.