Skip to content

Commit

Permalink
Merge pull request #2805 from MerginMaps/fix_crash_relations
Browse files Browse the repository at this point in the history
fix crash with broken relations
  • Loading branch information
PeterPetrik authored Sep 26, 2023
2 parents cbf75d5 + cb6daf6 commit 23b636a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/attributes/attributecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ void AttributeController::flatten(
int fieldIndex = editorField->idx();
if ( fieldIndex < 0 || fieldIndex >= layer->fields().size() )
{
qDebug() << "Invalid fieldIndex for editorField!";
CoreUtils::log( "Forms", QStringLiteral( "Invalid fieldIndex for editorField in layer %1" ).arg( layer->name() ) );
continue;
}
QgsField field = layer->fields().at( fieldIndex );
Expand Down Expand Up @@ -269,10 +269,17 @@ void AttributeController::flatten(
QgsAttributeEditorRelation *relationField = static_cast<QgsAttributeEditorRelation *>( element );
QgsRelation associatedRelation = relationField->relation();

bool isValid = associatedRelation.isValid();
if ( !isValid )
{
CoreUtils::log( "Relations", QStringLiteral( "Ignoring invalid relation in layer %1" ).arg( layer->name() ) );
continue;
}

bool isNmRelation = layer->editFormConfig().widgetConfig( associatedRelation.id() )[QStringLiteral( "nm-rel" )].toBool();
if ( isNmRelation )
{
CoreUtils::log( "Relations", "Nm relations are not supported" );
CoreUtils::log( "Relations", QStringLiteral( "Nm relations are not supported in layer %1" ).arg( layer->name() ) );
continue;
}

Expand Down

1 comment on commit 23b636a

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 23.09.458711 just submitted!

Please sign in to comment.