Skip to content

Commit f6a8e48

Browse files
author
mhugent
committed
Field calculator: insert NULL feature value in case of calculation error (instead of stopping and reverting calculation for all features)
git-svn-id: http://svn.osgeo.org/qgis/trunk@14369 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 7579e22 commit f6a8e48

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

src/app/qgsfieldcalculator.cpp

+3-16
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ void QgsFieldCalculator::accept()
145145

146146
//go through all the features and change the new attribute
147147
QgsFeature feature;
148-
bool calculationSuccess = true;
149148

150149
bool onlySelected = ( mOnlyUpdateSelectedCheckBox->checkState() == Qt::Checked );
151150
QgsFeatureIds selectedIds = mVectorLayer->selectedFeaturesIds();
@@ -173,10 +172,10 @@ void QgsFieldCalculator::accept()
173172
searchTree->getValue( value, searchTree, mVectorLayer->pendingFields(), feature );
174173
if ( value.isError() )
175174
{
176-
calculationSuccess = false;
177-
break;
175+
//insert NULL value for this feature and continue the calculation
176+
mVectorLayer->changeAttributeValue( feature.id(), attributeId, QVariant(), false );
178177
}
179-
if ( value.isNumeric() )
178+
else if ( value.isNumeric() )
180179
{
181180
mVectorLayer->changeAttributeValue( feature.id(), attributeId, value.number(), false );
182181
}
@@ -191,18 +190,6 @@ void QgsFieldCalculator::accept()
191190
// stop blocking layerModified signals and make sure that one layerModified signal is emitted
192191
mVectorLayer->blockSignals( false );
193192
mVectorLayer->setModified( true, false );
194-
195-
196-
if ( !calculationSuccess )
197-
{
198-
QMessageBox::critical( 0, tr( "Error" ), tr( "An error occured while evaluating the calculation string." ) );
199-
200-
//remove new attribute
201-
mVectorLayer->deleteAttribute( attributeId );
202-
mVectorLayer->destroyEditCommand();
203-
return;
204-
}
205-
206193
mVectorLayer->endEditCommand();
207194
}
208195
QDialog::accept();

0 commit comments

Comments
 (0)