Skip to content

Commit c9ec219

Browse files
author
Sandro Santilli
committedApr 24, 2015
Make QgsPointLocator discard geometries that cannot be projected
Fix #12634 (crash snapping in measure tool) (cherry picked from commit 0480cab)
1 parent a2d673f commit c9ec219

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
@@ -631,7 +631,14 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
631631
{
632632
QgsRectangle rect = *mExtent;
633633
if ( mTransform )
634-
rect = mTransform->transformBoundingBox( rect, QgsCoordinateTransform::ReverseTransform );
634+
{
635+
try {
636+
rect = mTransform->transformBoundingBox( rect, QgsCoordinateTransform::ReverseTransform );
637+
} catch (const QgsException& e) {
638+
// See http://hub.qgis.org/issues/12634
639+
QgsDebugMsg( QString("could not transform bounding box to map, skipping the snap filter (%1)").arg(e.what()) );
640+
}
641+
}
635642
request.setFilterRect( rect );
636643
}
637644
QgsFeatureIterator fi = mLayer->getFeatures( request );
@@ -642,7 +649,15 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
642649
continue;
643650

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

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

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.