Skip to content

Commit

Permalink
Fix crash when accessing out of bounds field
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Oct 27, 2017
1 parent c54299d commit 4c7eb83
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/gui/qgsattributeform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1514,8 +1514,9 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
if ( !fieldDef )
break;

int fldIdx = vl->fields().lookupField( fieldDef->name() );
if ( fldIdx < vl->fields().count() && fldIdx >= 0 )
const QgsFields fields = vl->fields();
int fldIdx = fields.lookupField( fieldDef->name() );
if ( fldIdx < fields.count() && fldIdx >= 0 )
{
const QgsEditorWidgetSetup widgetSetup = QgsGui::editorWidgetRegistry()->findBest( mLayer, fieldDef->name() );

Expand All @@ -1528,12 +1529,12 @@ QgsAttributeForm::WidgetInfo QgsAttributeForm::createWidgetFromDef( const QgsAtt
newWidgetInfo.widget = w;
addWidgetWrapper( eww );

newWidgetInfo.widget->setObjectName( mLayer->fields().at( fldIdx ).name() );
newWidgetInfo.widget->setObjectName( fields.at( fldIdx ).name() );
newWidgetInfo.hint = fields.at( fieldDef->idx() ).comment();
}

newWidgetInfo.labelOnTop = mLayer->editFormConfig().labelOnTop( fieldDef->idx() );
newWidgetInfo.labelText = mLayer->attributeDisplayName( fieldDef->idx() );
newWidgetInfo.hint = mLayer->fields().at( fieldDef->idx() ).comment();
newWidgetInfo.showLabel = widgetDef->showLabel();

break;
Expand Down

0 comments on commit 4c7eb83

Please sign in to comment.