Skip to content
Permalink
Browse files
Show a message box if there was an error during the merge operation (…
…instead of crashing). Fixes ticket #2342

git-svn-id: http://svn.osgeo.org/qgis/trunk@12673 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Jan 5, 2010
1 parent a9ae722 commit a8ce63c20bf48478334a64a8a11d4264d59fc6d2
Showing with 23 additions and 5 deletions.
  1. +21 −3 src/app/qgisapp.cpp
  2. +2 −2 src/app/qgisapp.h
@@ -3635,8 +3635,9 @@ void QgisApp::deletePart()
mMapCanvas->setMapTool( mMapTools.mDeletePart );
}

QgsGeometry* QgisApp::unionGeometries( const QgsVectorLayer* vl, QgsFeatureList& featureList )
QgsGeometry* QgisApp::unionGeometries( const QgsVectorLayer* vl, QgsFeatureList& featureList, bool& canceled )
{
canceled = false;
if ( !vl || featureList.size() < 2 )
{
return 0;
@@ -3660,6 +3661,7 @@ QgsGeometry* QgisApp::unionGeometries( const QgsVectorLayer* vl, QgsFeatureList&
{
delete unionGeom;
QApplication::restoreOverrideCursor();
canceled = true;
return 0;
}
progress.setValue( i );
@@ -3668,6 +3670,12 @@ QgsGeometry* QgisApp::unionGeometries( const QgsVectorLayer* vl, QgsFeatureList&
{
backupPtr = unionGeom;
unionGeom = unionGeom->combine( currentGeom );
if ( !unionGeom )
{
delete backupPtr;
QApplication::restoreOverrideCursor();
return 0;
}
if ( i > 1 ) //delete previous intermediate results
{
delete backupPtr;
@@ -3798,9 +3806,14 @@ void QgisApp::mergeSelectedFeatures()

//get initial selection (may be altered by attribute merge dialog later)
QgsFeatureList featureList = vl->selectedFeatures(); //get QList<QgsFeature>
QgsGeometry* unionGeom = unionGeometries( vl, featureList );
bool canceled;
QgsGeometry* unionGeom = unionGeometries( vl, featureList, canceled );
if ( !unionGeom )
{
if ( !canceled )
{
QMessageBox::critical( 0, tr( "Merge failed" ), tr( "An error occured during the merge operation" ) );
}
return;
}

@@ -3835,9 +3848,14 @@ void QgisApp::mergeSelectedFeatures()
if ( featureList.size() != featureListAfter.size() )
{
delete unionGeom;
unionGeom = unionGeometries( vl, featureListAfter );
bool canceled;
unionGeom = unionGeometries( vl, featureListAfter, canceled );
if ( !unionGeom )
{
if ( !canceled )
{
QMessageBox::critical( 0, tr( "Merge failed" ), tr( "An error occured during the merge operation" ) );
}
return;
}

@@ -710,8 +710,8 @@ class QgisApp : public QMainWindow
//! check to see if file is dirty and if so, prompt the user th save it
bool saveDirty();
/** Helper function to union several geometries together (used in function mergeSelectedFeatures)
@return 0 in case of error*/
QgsGeometry* unionGeometries( const QgsVectorLayer* vl, QgsFeatureList& featureList );
@return 0 in case of error or if canceled*/
QgsGeometry* unionGeometries( const QgsVectorLayer* vl, QgsFeatureList& featureList, bool& canceled );

/**Deletes all the composer objects and clears mPrintComposers*/
void deletePrintComposers();

0 comments on commit a8ce63c

Please sign in to comment.