Skip to content

Commit

Permalink
Catch GEOS exceptions when reshape tool is used on non-closed-linestring
Browse files Browse the repository at this point in the history
And use qWarning() instead of QgsDebugMsg() to make tracing GEOS errors easier
because a stack trace is printed.
  • Loading branch information
m-kuhn committed Oct 21, 2014
1 parent 58c34ae commit 37f1a16
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/core/qgsgeometry.cpp
Expand Up @@ -32,6 +32,8 @@ email : morb at ozemail dot com dot au
#include "qgsmessagelog.h"
#include "qgsgeometryvalidator.h"

#include <QDebug>

#ifndef Q_WS_WIN
#include <netinet/in.h>
#else
Expand Down Expand Up @@ -96,7 +98,7 @@ static void throwGEOSException( const char *fmt, ... )
vsnprintf( buffer, sizeof buffer, fmt, ap );
va_end( ap );

QgsDebugMsg( QString( "GEOS exception: %1" ).arg( buffer ) );
qWarning() << QString( "GEOS exception: %1" ).arg( buffer );

throw GEOSException( QString::fromUtf8( buffer ) );
}
Expand Down Expand Up @@ -4877,7 +4879,15 @@ GEOSGeometry* QgsGeometry::reshapePolygon( const GEOSGeometry* polygon, const GE

GEOSGeom_destroy_r( geosinit.ctxt, reshapeResult );

newRing = GEOSGeom_createLinearRing_r( geosinit.ctxt, newCoordSequence );
try
{
newRing = GEOSGeom_createLinearRing_r( geosinit.ctxt, newCoordSequence );
}
catch ( GEOSException &e )
{
QgsMessageLog::logMessage( QObject::tr( "Exception: %1" ).arg( e.what() ), QObject::tr( "GEOS" ) );
}

if ( !newRing )
{
delete [] innerRings;
Expand Down

0 comments on commit 37f1a16

Please sign in to comment.