@@ -3635,8 +3635,9 @@ void QgisApp::deletePart()
36353635 mMapCanvas ->setMapTool ( mMapTools .mDeletePart );
36363636}
36373637
3638- QgsGeometry* QgisApp::unionGeometries ( const QgsVectorLayer* vl, QgsFeatureList& featureList )
3638+ QgsGeometry* QgisApp::unionGeometries ( const QgsVectorLayer* vl, QgsFeatureList& featureList, bool & canceled )
36393639{
3640+ canceled = false ;
36403641 if ( !vl || featureList.size () < 2 )
36413642 {
36423643 return 0 ;
@@ -3660,6 +3661,7 @@ QgsGeometry* QgisApp::unionGeometries( const QgsVectorLayer* vl, QgsFeatureList&
36603661 {
36613662 delete unionGeom;
36623663 QApplication::restoreOverrideCursor ();
3664+ canceled = true ;
36633665 return 0 ;
36643666 }
36653667 progress.setValue ( i );
@@ -3668,6 +3670,12 @@ QgsGeometry* QgisApp::unionGeometries( const QgsVectorLayer* vl, QgsFeatureList&
36683670 {
36693671 backupPtr = unionGeom;
36703672 unionGeom = unionGeom->combine ( currentGeom );
3673+ if ( !unionGeom )
3674+ {
3675+ delete backupPtr;
3676+ QApplication::restoreOverrideCursor ();
3677+ return 0 ;
3678+ }
36713679 if ( i > 1 ) // delete previous intermediate results
36723680 {
36733681 delete backupPtr;
@@ -3798,9 +3806,14 @@ void QgisApp::mergeSelectedFeatures()
37983806
37993807 // get initial selection (may be altered by attribute merge dialog later)
38003808 QgsFeatureList featureList = vl->selectedFeatures (); // get QList<QgsFeature>
3801- QgsGeometry* unionGeom = unionGeometries ( vl, featureList );
3809+ bool canceled;
3810+ QgsGeometry* unionGeom = unionGeometries ( vl, featureList, canceled );
38023811 if ( !unionGeom )
38033812 {
3813+ if ( !canceled )
3814+ {
3815+ QMessageBox::critical ( 0 , tr ( " Merge failed" ), tr ( " An error occured during the merge operation" ) );
3816+ }
38043817 return ;
38053818 }
38063819
@@ -3835,9 +3848,14 @@ void QgisApp::mergeSelectedFeatures()
38353848 if ( featureList.size () != featureListAfter.size () )
38363849 {
38373850 delete unionGeom;
3838- unionGeom = unionGeometries ( vl, featureListAfter );
3851+ bool canceled;
3852+ unionGeom = unionGeometries ( vl, featureListAfter, canceled );
38393853 if ( !unionGeom )
38403854 {
3855+ if ( !canceled )
3856+ {
3857+ QMessageBox::critical ( 0 , tr ( " Merge failed" ), tr ( " An error occured during the merge operation" ) );
3858+ }
38413859 return ;
38423860 }
38433861
0 commit comments