Skip to content

Commit

Permalink
When resetting the attribute form model, clear the containers QMap to…
Browse files Browse the repository at this point in the history
… avoid crashers
  • Loading branch information
nirvn committed Oct 14, 2023
1 parent 5fb8a75 commit e66fee1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/core/attributeformmodelbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void AttributeFormModelBase::resetModel()

mVisibilityExpressions.clear();
mConstraints.clear();
mEditorWidgetCodes.clear();

setHasTabs( false );

Expand Down Expand Up @@ -501,11 +502,10 @@ void AttributeFormModelBase::buildForm( QgsAttributeEditorContainer *container,
item->setData( false, AttributeFormModel::AttributeEditable );
item->setData( false, AttributeFormModel::AttributeAllowEdit );

mEditorWidgetCodes.insert( item, qmlElement->qmlCode() );

updateAttributeValue( item );

parent->appendRow( item );
mEditorWidgetCodes.insert( item, qmlElement->qmlCode() );
break;
}

Expand All @@ -523,11 +523,9 @@ void AttributeFormModelBase::buildForm( QgsAttributeEditorContainer *container,
item->setData( false, AttributeFormModel::AttributeEditable );
item->setData( false, AttributeFormModel::AttributeAllowEdit );

mEditorWidgetCodes.insert( item, htmlElement->htmlCode() );

updateAttributeValue( item );

parent->appendRow( item );
mEditorWidgetCodes.insert( item, htmlElement->htmlCode() );
break;
}

Expand All @@ -542,11 +540,9 @@ void AttributeFormModelBase::buildForm( QgsAttributeEditorContainer *container,
item->setData( false, AttributeFormModel::AttributeEditable );
item->setData( false, AttributeFormModel::AttributeAllowEdit );

mEditorWidgetCodes.insert( item, textElement->text() );

updateAttributeValue( item );

parent->appendRow( item );
mEditorWidgetCodes.insert( item, textElement->text() );
break;
}
case Qgis::AttributeEditorType::Action:
Expand Down Expand Up @@ -627,6 +623,10 @@ void AttributeFormModelBase::updateEditorWidgetCodes( const QString &fieldName )
for ( ; editorWidgetCodesIterator != mEditorWidgetCodes.constEnd(); editorWidgetCodesIterator++ )
{
QStandardItem *item = editorWidgetCodesIterator.key();
if ( !item )
{
continue;
}
QString code = editorWidgetCodesIterator.value();
bool needUpdate = false;

Expand Down

1 comment on commit e66fee1

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please sign in to comment.