Skip to content

Commit

Permalink
Field calculator: insert NULL feature value in case of calculation er…
Browse files Browse the repository at this point in the history
…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 committed Oct 11, 2010
1 parent 92e3c05 commit e47af8c
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions src/app/qgsfieldcalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 );
}
Expand All @@ -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();
Expand Down

0 comments on commit e47af8c

Please sign in to comment.