Skip to content
Permalink
Browse files

Fields of non existent joined features are set to NULL

  • Loading branch information
pblottiere committed Jul 3, 2017
1 parent 257f35c commit 5253aa80e2b222a45c99abffa2bfa7d71f013050
Showing with 13 additions and 15 deletions.
  1. +13 −13 src/gui/qgsattributeform.cpp
  2. +0 −2 src/gui/qgsattributeform.h
@@ -1936,16 +1936,6 @@ void QgsAttributeForm::ContainerInformation::apply( QgsExpressionContext *expres
}
}

QgsFeature QgsAttributeForm::joinedFeature( const QgsVectorLayerJoinInfo *info, const QgsFeature &feature ) const
{
QgsFeature joinedFeature = mLayer->joinBuffer()->joinedFeatureOf( info, feature );

if ( !joinedFeature.isValid() )
joinedFeature = QgsVectorLayerUtils::createFeature( info->joinLayer(), QgsGeometry(), QgsAttributeMap() );

return joinedFeature;
}

void QgsAttributeForm::updateJoinedFields( const QgsEditorWidgetWrapper &eww )
{
QgsFeature formFeature;
@@ -1960,23 +1950,33 @@ void QgsAttributeForm::updateJoinedFields( const QgsEditorWidgetWrapper &eww )
if ( !info->isDynamicFormEnabled() )
continue;

QgsFeature joinFeature = joinedFeature( info, formFeature );
QgsFeature joinFeature = mLayer->joinBuffer()->joinedFeatureOf( info, formFeature );

QStringList *subsetFields = info->joinFieldNamesSubset();
if ( subsetFields )
{
Q_FOREACH ( const QString &field, *subsetFields )
{
QString prefixedName = info->prefixedFieldName( field );
changeAttribute( prefixedName, joinFeature.attribute( field ) );
QVariant val;

if ( joinFeature.isValid() )
val = joinFeature.attribute( field );

changeAttribute( prefixedName, val );
}
}
else
{
Q_FOREACH ( const QgsField &field, joinFeature.fields() )
{
QString prefixedName = info->prefixedFieldName( field );
changeAttribute( prefixedName, joinFeature.attribute( field.name() ) );
QVariant val;

if ( joinFeature.isValid() )
val = joinFeature.attribute( field.name() );

changeAttribute( prefixedName, val );
}
}
}
@@ -273,8 +273,6 @@ class GUI_EXPORT QgsAttributeForm : public QWidget

void initPython();

QgsFeature joinedFeature( const QgsVectorLayerJoinInfo *info, const QgsFeature &feature ) const;

void updateJoinedFields( const QgsEditorWidgetWrapper &eww );

struct WidgetInfo

0 comments on commit 5253aa8

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