Skip to content
Permalink
Browse files

Fix crash when accessing out of bounds field

  • Loading branch information
m-kuhn committed Oct 27, 2017
1 parent c54299d commit 4c7eb8327bcbce0724ae9966bc0baec372179b84
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/gui/qgsattributeform.cpp
@@ -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() );

@@ -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;

0 comments on commit 4c7eb83

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