@@ -632,11 +632,14 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
632
632
QgsRectangle rect = *mExtent ;
633
633
if ( mTransform )
634
634
{
635
- try {
635
+ try
636
+ {
636
637
rect = mTransform ->transformBoundingBox ( rect, QgsCoordinateTransform::ReverseTransform );
637
- } catch (const QgsException& e) {
638
+ }
639
+ catch ( const QgsException& e )
640
+ {
638
641
// 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 ()) );
642
+ QgsDebugMsg ( QString ( " could not transform bounding box to map, skipping the snap filter (%1)" ).arg ( e.what () ) );
640
643
}
641
644
}
642
645
request.setFilterRect ( rect );
@@ -650,11 +653,14 @@ bool QgsPointLocator::rebuildIndex( int maxFeaturesToIndex )
650
653
651
654
if ( mTransform )
652
655
{
653
- try {
656
+ try
657
+ {
654
658
f.geometry ()->transform ( *mTransform );
655
- } catch (const QgsException& e) {
659
+ }
660
+ catch ( const QgsException& e )
661
+ {
656
662
// 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 ()) );
663
+ QgsDebugMsg ( QString ( " could not transform geometry to map, skipping the snap for it (%1)" ).arg ( e.what () ) );
658
664
continue ;
659
665
}
660
666
}
@@ -700,8 +706,8 @@ void QgsPointLocator::destroyIndex()
700
706
701
707
mIsEmptyLayer = false ;
702
708
703
- foreach ( QgsGeometry* g, mGeoms )
704
- delete g;
709
+ qDeleteAll ( mGeoms );
710
+
705
711
mGeoms .clear ();
706
712
}
707
713
@@ -722,18 +728,25 @@ void QgsPointLocator::onFeatureAdded( QgsFeatureId fid )
722
728
723
729
if ( mTransform )
724
730
{
725
- try {
731
+ try
732
+ {
726
733
f.geometry ()->transform ( *mTransform );
727
- } catch (const QgsException& e) {
734
+ }
735
+ catch ( const QgsException& e )
736
+ {
728
737
// 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 ()) );
738
+ QgsDebugMsg ( QString ( " could not transform geometry to map, skipping the snap for it (%1)" ).arg ( e.what () ) );
730
739
return ;
731
740
}
732
741
}
733
742
734
- SpatialIndex::Region r ( rect2region ( f.geometry ()->boundingBox () ) );
735
- mRTree ->insertData ( 0 , 0 , r, f.id () );
736
- mGeoms [fid] = new QgsGeometry ( *f.geometry () );
743
+ QgsRectangle bbox = f.geometry ()->boundingBox ();
744
+ if ( !bbox.isNull () )
745
+ {
746
+ SpatialIndex::Region r ( rect2region ( bbox ) );
747
+ mRTree ->insertData ( 0 , 0 , r, f.id () );
748
+ mGeoms [fid] = new QgsGeometry ( *f.geometry () );
749
+ }
737
750
}
738
751
}
739
752
0 commit comments