Skip to content

Commit

Permalink
Merge pull request #37105 from m-kuhn/safety_guard_attribute_alias
Browse files Browse the repository at this point in the history
Add safety guard for DD attribute alias
  • Loading branch information
elpaso committed Jun 10, 2020
2 parents 7d58502 + 7cb484c commit 13bd846
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/gui/qgsattributeform.cpp
Expand Up @@ -1485,13 +1485,17 @@ void QgsAttributeForm::init()
if ( widgDef->type() == QgsAttributeEditorElement::AttributeEditorType::AeTypeField )
{
const QgsAttributeEditorField *fieldElement { static_cast<QgsAttributeEditorField *>( widgDef ) };
const QString fieldName { mLayer->fields().at( fieldElement->idx() ).name() };
if ( mLayer->editFormConfig().dataDefinedFieldProperties( fieldName ).hasProperty( QgsEditFormConfig::DataDefinedProperty::Alias ) )
const int fieldIdx = fieldElement->idx();
if ( fieldIdx >= 0 && fieldIdx < mLayer->fields().count() )
{
const QgsProperty property { mLayer->editFormConfig().dataDefinedFieldProperties( fieldName ).property( QgsEditFormConfig::DataDefinedProperty::Alias ) };
if ( property.isActive() && ! property.expressionString().isEmpty() )
const QString fieldName { mLayer->fields().at( fieldIdx ).name() };
if ( mLayer->editFormConfig().dataDefinedFieldProperties( fieldName ).hasProperty( QgsEditFormConfig::DataDefinedProperty::Alias ) )
{
mLabelDataDefinedProperties[ label ] = property;
const QgsProperty property { mLayer->editFormConfig().dataDefinedFieldProperties( fieldName ).property( QgsEditFormConfig::DataDefinedProperty::Alias ) };
if ( property.isActive() && ! property.expressionString().isEmpty() )
{
mLabelDataDefinedProperties[ label ] = property;
}
}
}
}
Expand Down

0 comments on commit 13bd846

Please sign in to comment.