Skip to content
Permalink
Browse files

Field calculator: insert NULL feature value in case of calculation er…

…ror (instead of stopping and reverting calculation for all features)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14369 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Oct 11, 2010
1 parent 92e3c05 commit e47af8c1ceca5558f8feb76f8af9494b9717b15e
Showing with 3 additions and 16 deletions.
  1. +3 −16 src/app/qgsfieldcalculator.cpp
@@ -145,7 +145,6 @@ void QgsFieldCalculator::accept()

//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();
@@ -173,10 +172,10 @@ void QgsFieldCalculator::accept()
searchTree->getValue( value, searchTree, mVectorLayer->pendingFields(), feature );
if ( value.isError() )
{
calculationSuccess = false;
break;
//insert NULL value for this feature and continue the calculation
mVectorLayer->changeAttributeValue( feature.id(), attributeId, QVariant(), false );
}
if ( value.isNumeric() )
else if ( value.isNumeric() )
{
mVectorLayer->changeAttributeValue( feature.id(), attributeId, value.number(), false );
}
@@ -191,18 +190,6 @@ void QgsFieldCalculator::accept()
// 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." ) );

//remove new attribute
mVectorLayer->deleteAttribute( attributeId );
mVectorLayer->destroyEditCommand();
return;
}

mVectorLayer->endEditCommand();
}
QDialog::accept();

0 comments on commit e47af8c

Please sign in to comment.
You can’t perform that action at this time.