Skip to content

Commit 37f1a16

Browse files
committedOct 21, 2014
Catch GEOS exceptions when reshape tool is used on non-closed-linestring
And use qWarning() instead of QgsDebugMsg() to make tracing GEOS errors easier because a stack trace is printed.
1 parent 58c34ae commit 37f1a16

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed
 

‎src/core/qgsgeometry.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ email : morb at ozemail dot com dot au
3232
#include "qgsmessagelog.h"
3333
#include "qgsgeometryvalidator.h"
3434

35+
#include <QDebug>
36+
3537
#ifndef Q_WS_WIN
3638
#include <netinet/in.h>
3739
#else
@@ -96,7 +98,7 @@ static void throwGEOSException( const char *fmt, ... )
9698
vsnprintf( buffer, sizeof buffer, fmt, ap );
9799
va_end( ap );
98100

99-
QgsDebugMsg( QString( "GEOS exception: %1" ).arg( buffer ) );
101+
qWarning() << QString( "GEOS exception: %1" ).arg( buffer );
100102

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

48784880
GEOSGeom_destroy_r( geosinit.ctxt, reshapeResult );
48794881

4880-
newRing = GEOSGeom_createLinearRing_r( geosinit.ctxt, newCoordSequence );
4882+
try
4883+
{
4884+
newRing = GEOSGeom_createLinearRing_r( geosinit.ctxt, newCoordSequence );
4885+
}
4886+
catch ( GEOSException &e )
4887+
{
4888+
QgsMessageLog::logMessage( QObject::tr( "Exception: %1" ).arg( e.what() ), QObject::tr( "GEOS" ) );
4889+
}
4890+
48814891
if ( !newRing )
48824892
{
48834893
delete [] innerRings;

0 commit comments

Comments
 (0)