[QGIS Commit] r14557 - trunk/qgis/src/app
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Nov 12 11:24:42 EST 2010
Author: mhugent
Date: 2010-11-12 08:24:42 -0800 (Fri, 12 Nov 2010)
New Revision: 14557
Modified:
trunk/qgis/src/app/qgsfieldcalculator.cpp
Log:
Continue field calculation upon error only for division through zero
Modified: trunk/qgis/src/app/qgsfieldcalculator.cpp
===================================================================
--- trunk/qgis/src/app/qgsfieldcalculator.cpp 2010-11-12 14:33:46 UTC (rev 14556)
+++ trunk/qgis/src/app/qgsfieldcalculator.cpp 2010-11-12 16:24:42 UTC (rev 14557)
@@ -143,6 +143,7 @@
//go through all the features and change the new attribute
QgsFeature feature;
+ bool calculationSuccess = true;
bool onlySelected = ( mOnlyUpdateSelectedCheckBox->checkState() == Qt::Checked );
QgsFeatureIds selectedIds = mVectorLayer->selectedFeaturesIds();
@@ -171,7 +172,15 @@
if ( value.isError() )
{
//insert NULL value for this feature and continue the calculation
- mVectorLayer->changeAttributeValue( feature.id(), attributeId, QVariant(), false );
+ if( searchTree->errorMsg() == QObject::tr( "Division by zero." ) )
+ {
+ mVectorLayer->changeAttributeValue( feature.id(), attributeId, QVariant(), false );
+ }
+ else
+ {
+ calculationSuccess = false;
+ break;
+ }
}
else if ( value.isNumeric() )
{
@@ -188,6 +197,14 @@
// stop blocking layerModified signals and make sure that one layerModified signal is emitted
mVectorLayer->blockSignals( false );
mVectorLayer->setModified( true, false );
+
+ if ( !calculationSuccess )
+ {
+ QMessageBox::critical( 0, tr( "Error" ), tr( "An error occured while evaluating the calculation string." ) );
+ mVectorLayer->destroyEditCommand();
+ return;
+ }
+
mVectorLayer->endEditCommand();
}
QDialog::accept();
More information about the QGIS-commit
mailing list