Skip to content

Commit 2973e85

Browse files
committed
"Fix" crash in attribute table field calculator
1 parent 3ed98f1 commit 2973e85

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/app/qgsattributetabledialog.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,13 @@ void QgsAttributeTableDialog::runFieldCalculation( QgsVectorLayer *layer, const
495495
mLayer->beginEditCommand( QStringLiteral( "Field calculator" ) );
496496

497497
int fieldindex = layer->fields().indexFromName( fieldName );
498+
if ( fieldindex < 0 )
499+
{
500+
// this shouldn't happen... but it did. There's probably some deeper underlying issue
501+
// but we may as well play it safe here.
502+
QMessageBox::critical( nullptr, tr( "Update Attributes" ), tr( "An error occurred while trying to update the field %1" ).arg( fieldName ) );
503+
return;
504+
}
498505

499506
bool calculationSuccess = true;
500507
QString error;

0 commit comments

Comments
 (0)