Skip to content

Commit ac7f0c5

Browse files
author
jef
committed
catch exceptions in QgsSpatialIndex
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9089 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9bf6208 commit ac7f0c5

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/core/spatialindex/qgsspatialindex.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "qgsgeometry.h"
2020
#include "qgsfeature.h"
2121
#include "qgsrect.h"
22+
#include "qgslogger.h"
2223

2324
#include "SpatialIndex.h"
2425

@@ -89,7 +90,7 @@ Tools::Geometry::Region QgsSpatialIndex::rectToRegion(QgsRect rect)
8990

9091
bool QgsSpatialIndex::featureInfo(QgsFeature& f, Tools::Geometry::Region& r, long& id)
9192
{
92-
QgsGeometry* g = f.geometry();
93+
QgsGeometry *g = f.geometry();
9394
if (!g)
9495
return false;
9596

@@ -105,8 +106,16 @@ bool QgsSpatialIndex::insertFeature(QgsFeature& f)
105106
if (!featureInfo(f, r, id))
106107
return false;
107108

108-
// TODO: handle possible exceptions
109-
mRTree->insertData(0,0, r, id);
109+
// TODO: handle possible exceptions correctly
110+
try {
111+
mRTree->insertData(0,0, r, id);
112+
} catch(Tools::Exception &e) {
113+
QgsDebugMsg( QString("Tools::Exception caught: ").arg(e.what().c_str()) );
114+
} catch(const std::exception &e) {
115+
QgsDebugMsg( QString("std::exception caught: ").arg(e.what()) );
116+
} catch(...) {
117+
QgsDebugMsg( "unknown spatial index exception caught" );
118+
}
110119

111120
return true;
112121
}

0 commit comments

Comments
 (0)