Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make QgsPointLocator discard geometries that cannot be projected
Fix #12634 (crash snapping in measure tool)

(cherry picked from commit 0480cab)
  • Loading branch information
Sandro Santilli committed Apr 24, 2015
1 parent a2d673f commit c9ec219
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/core/qgspointlocator.cpp
Expand Up @@ -631,7 +631,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 );
Expand All @@ -642,7 +649,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() );
Expand Down Expand Up @@ -706,7 +721,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() );
Expand Down

0 comments on commit c9ec219

Please sign in to comment.