Skip to content
Permalink
Browse files

Make QgsPointLocator discard geometries that cannot be projected

Fix #12634 (crash snapping in measure tool)
To be backported to 2.8 branch
  • Loading branch information
Sandro Santilli
Sandro Santilli committed Apr 24, 2015
1 parent 876e54b commit 0480cabfc91353156c58285b5748ef1c83bbe5d7
Showing with 26 additions and 3 deletions.
  1. +26 −3 src/core/qgspointlocator.cpp
@@ -633,7 +633,14 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
{
QgsRectangle rect = *mExtent;
if ( mTransform )
rect = mTransform->transformBoundingBox( rect, QgsCoordinateTransform::ReverseTransform );
{
try {
rect = mTransform->transformBoundingBox( rect, QgsCoordinateTransform::ReverseTransform );
} catch (const QgsException& e) {
// See http://hub.qgis.org/issues/12634
QgsDebugMsg( QString("could not transform bounding box to map, skipping the snap filter (%1)").arg(e.what()) );
}
}
request.setFilterRect( rect );
}
QgsFeatureIterator fi = mLayer->getFeatures( request );
@@ -644,7 +651,15 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
continue;

if ( mTransform )
f.geometry()->transform( *mTransform );
{
try {
f.geometry()->transform( *mTransform );
} catch (const QgsException& e) {
// See http://hub.qgis.org/issues/12634
QgsDebugMsg( QString("could not transform geometry to map, skipping the snap for it (%1)").arg(e.what()) );
continue;
}
}

SpatialIndex::Region r( rect2region( f.geometry()->boundingBox() ) );
dataList << new RTree::Data( 0, 0, r, f.id() );
@@ -708,7 +723,15 @@ void QgsPointLocator::onFeatureAdded( QgsFeatureId fid )
return;

if ( mTransform )
f.geometry()->transform( *mTransform );
{
try {
f.geometry()->transform( *mTransform );
} catch (const QgsException& e) {
// See http://hub.qgis.org/issues/12634
QgsDebugMsg( QString("could not transform geometry to map, skipping the snap for it (%1)").arg(e.what()) );
return;
}
}

SpatialIndex::Region r( rect2region( f.geometry()->boundingBox() ) );
mRTree->insertData( 0, 0, r, f.id() );

0 comments on commit 0480cab

Please sign in to comment.
You can’t perform that action at this time.