@@ -3635,8 +3635,9 @@ void QgisApp::deletePart()
3635
3635
mMapCanvas ->setMapTool ( mMapTools .mDeletePart );
3636
3636
}
3637
3637
3638
- QgsGeometry* QgisApp::unionGeometries ( const QgsVectorLayer* vl, QgsFeatureList& featureList )
3638
+ QgsGeometry* QgisApp::unionGeometries ( const QgsVectorLayer* vl, QgsFeatureList& featureList, bool & canceled )
3639
3639
{
3640
+ canceled = false ;
3640
3641
if ( !vl || featureList.size () < 2 )
3641
3642
{
3642
3643
return 0 ;
@@ -3660,6 +3661,7 @@ QgsGeometry* QgisApp::unionGeometries( const QgsVectorLayer* vl, QgsFeatureList&
3660
3661
{
3661
3662
delete unionGeom;
3662
3663
QApplication::restoreOverrideCursor ();
3664
+ canceled = true ;
3663
3665
return 0 ;
3664
3666
}
3665
3667
progress.setValue ( i );
@@ -3668,6 +3670,12 @@ QgsGeometry* QgisApp::unionGeometries( const QgsVectorLayer* vl, QgsFeatureList&
3668
3670
{
3669
3671
backupPtr = unionGeom;
3670
3672
unionGeom = unionGeom->combine ( currentGeom );
3673
+ if ( !unionGeom )
3674
+ {
3675
+ delete backupPtr;
3676
+ QApplication::restoreOverrideCursor ();
3677
+ return 0 ;
3678
+ }
3671
3679
if ( i > 1 ) // delete previous intermediate results
3672
3680
{
3673
3681
delete backupPtr;
@@ -3798,9 +3806,14 @@ void QgisApp::mergeSelectedFeatures()
3798
3806
3799
3807
// get initial selection (may be altered by attribute merge dialog later)
3800
3808
QgsFeatureList featureList = vl->selectedFeatures (); // get QList<QgsFeature>
3801
- QgsGeometry* unionGeom = unionGeometries ( vl, featureList );
3809
+ bool canceled;
3810
+ QgsGeometry* unionGeom = unionGeometries ( vl, featureList, canceled );
3802
3811
if ( !unionGeom )
3803
3812
{
3813
+ if ( !canceled )
3814
+ {
3815
+ QMessageBox::critical ( 0 , tr ( " Merge failed" ), tr ( " An error occured during the merge operation" ) );
3816
+ }
3804
3817
return ;
3805
3818
}
3806
3819
@@ -3835,9 +3848,14 @@ void QgisApp::mergeSelectedFeatures()
3835
3848
if ( featureList.size () != featureListAfter.size () )
3836
3849
{
3837
3850
delete unionGeom;
3838
- unionGeom = unionGeometries ( vl, featureListAfter );
3851
+ bool canceled;
3852
+ unionGeom = unionGeometries ( vl, featureListAfter, canceled );
3839
3853
if ( !unionGeom )
3840
3854
{
3855
+ if ( !canceled )
3856
+ {
3857
+ QMessageBox::critical ( 0 , tr ( " Merge failed" ), tr ( " An error occured during the merge operation" ) );
3858
+ }
3841
3859
return ;
3842
3860
}
3843
3861
0 commit comments