Skip to content

Commit 0480cab

Browse files
author
Sandro Santilli
committedApr 24, 2015
Make QgsPointLocator discard geometries that cannot be projected
Fix #12634 (crash snapping in measure tool) To be backported to 2.8 branch
1 parent 876e54b commit 0480cab

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed
 

‎src/core/qgspointlocator.cpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,14 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
633633
{
634634
QgsRectangle rect = *mExtent;
635635
if ( mTransform )
636-
rect = mTransform->transformBoundingBox( rect, QgsCoordinateTransform::ReverseTransform );
636+
{
637+
try {
638+
rect = mTransform->transformBoundingBox( rect, QgsCoordinateTransform::ReverseTransform );
639+
} catch (const QgsException& e) {
640+
// See http://hub.qgis.org/issues/12634
641+
QgsDebugMsg( QString("could not transform bounding box to map, skipping the snap filter (%1)").arg(e.what()) );
642+
}
643+
}
637644
request.setFilterRect( rect );
638645
}
639646
QgsFeatureIterator fi = mLayer->getFeatures( request );
@@ -644,7 +651,15 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
644651
continue;
645652

646653
if ( mTransform )
647-
f.geometry()->transform( *mTransform );
654+
{
655+
try {
656+
f.geometry()->transform( *mTransform );
657+
} catch (const QgsException& e) {
658+
// See http://hub.qgis.org/issues/12634
659+
QgsDebugMsg( QString("could not transform geometry to map, skipping the snap for it (%1)").arg(e.what()) );
660+
continue;
661+
}
662+
}
648663

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

710725
if ( mTransform )
711-
f.geometry()->transform( *mTransform );
726+
{
727+
try {
728+
f.geometry()->transform( *mTransform );
729+
} catch (const QgsException& e) {
730+
// See http://hub.qgis.org/issues/12634
731+
QgsDebugMsg( QString("could not transform geometry to map, skipping the snap for it (%1)").arg(e.what()) );
732+
return;
733+
}
734+
}
712735

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

0 commit comments

Comments
 (0)
Please sign in to comment.