[QGIS Commit] r14904 - trunk/qgis/src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Dec 13 15:40:44 EST 2010


Author: wonder
Date: 2010-12-13 12:40:44 -0800 (Mon, 13 Dec 2010)
New Revision: 14904

Modified:
   trunk/qgis/src/core/qgsgeometry.cpp
Log:
Handle GEOS exception when parsing WKT


Modified: trunk/qgis/src/core/qgsgeometry.cpp
===================================================================
--- trunk/qgis/src/core/qgsgeometry.cpp	2010-12-13 20:23:19 UTC (rev 14903)
+++ trunk/qgis/src/core/qgsgeometry.cpp	2010-12-13 20:40:44 UTC (rev 14904)
@@ -406,14 +406,22 @@
 
 QgsGeometry* QgsGeometry::fromWkt( QString wkt )
 {
+  try
+  {
 #if defined(GEOS_VERSION_MAJOR) && (GEOS_VERSION_MAJOR>=3)
-  GEOSWKTReader *reader = GEOSWKTReader_create();;
-  QgsGeometry *g = fromGeosGeom( GEOSWKTReader_read( reader, wkt.toLocal8Bit().data() ) );
-  GEOSWKTReader_destroy( reader );
-  return g;
+    GEOSWKTReader *reader = GEOSWKTReader_create();
+    QgsGeometry *g = fromGeosGeom( GEOSWKTReader_read( reader, wkt.toLocal8Bit().data() ) );
+    GEOSWKTReader_destroy( reader );
+    return g;
 #else
-  return fromGeosGeom( GEOSGeomFromWKT( wkt.toLocal8Bit().data() ) );
+    return fromGeosGeom( GEOSGeomFromWKT( wkt.toLocal8Bit().data() ) );
 #endif
+  }
+  catch ( GEOSException &e )
+  {
+    Q_UNUSED( e );
+    return 0;
+  }
 }
 
 QgsGeometry* QgsGeometry::fromPoint( const QgsPoint& point )



More information about the QGIS-commit mailing list