mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Avoid recursion in apply on update default values
This commit is contained in:
parent
cf77ffe85b
commit
2fbb6f09cc
@ -925,13 +925,16 @@ Return the provider type for this layer
|
||||
virtual bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = 0 );
|
||||
|
||||
|
||||
bool updateFeature( const QgsFeature &f );
|
||||
bool updateFeature( const QgsFeature &feature, bool skipDefaultValues = false );
|
||||
%Docstring
|
||||
Updates an existing feature. This method needs to query the datasource
|
||||
on every call. Consider using changeAttributeValue() or
|
||||
changeGeometry() instead.
|
||||
\param f Feature to update
|
||||
:return: True in case of success and False in case of error
|
||||
on every call. Consider using changeAttributeValue() or
|
||||
changeGeometry() instead. The id of the feature will be used to match
|
||||
an existing feature.
|
||||
|
||||
\param feature Feature with changed geometry or attributes.
|
||||
\param skipDefaultValues Default values will not be updated if this is true. False by default.
|
||||
:return: True in case of success and False in case of error
|
||||
:rtype: bool
|
||||
%End
|
||||
|
||||
|
@ -164,12 +164,10 @@ class APP_EXPORT QgsAttributeTypeDialog: public QDialog, private Ui::QgsAttribut
|
||||
*/
|
||||
void setDefaultValueExpression( const QString &expression );
|
||||
|
||||
|
||||
|
||||
QgsExpressionContext createExpressionContext() const override;
|
||||
|
||||
bool applyDefaultValueOnUpdate() const;
|
||||
void setApplyDefaultValueOnUpdate(bool applyDefaultValueOnUpdate);
|
||||
void setApplyDefaultValueOnUpdate( bool applyDefaultValueOnUpdate );
|
||||
|
||||
private slots:
|
||||
|
||||
|
@ -780,8 +780,7 @@ void QgsVectorLayer::updateDefaultValues( QgsFeatureId fid, QgsFeature feature )
|
||||
continue;
|
||||
|
||||
feature.setAttribute( idx, defaultValue( idx, feature ) );
|
||||
// TODO catch recursion!!
|
||||
updateFeature( feature );
|
||||
updateFeature( feature, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -961,7 +960,7 @@ bool QgsVectorLayer::addFeature( QgsFeature &feature, Flags )
|
||||
return success;
|
||||
}
|
||||
|
||||
bool QgsVectorLayer::updateFeature( const QgsFeature &updatedFeature )
|
||||
bool QgsVectorLayer::updateFeature( const QgsFeature &updatedFeature, bool skipDefaultValues )
|
||||
{
|
||||
bool hasChanged = false;
|
||||
bool hasError = false;
|
||||
@ -1003,7 +1002,7 @@ bool QgsVectorLayer::updateFeature( const QgsFeature &updatedFeature )
|
||||
}
|
||||
}
|
||||
|
||||
if ( hasChanged && !mDefaultValueOnUpdateFields.isEmpty() )
|
||||
if ( hasChanged && !mDefaultValueOnUpdateFields.isEmpty() && !skipDefaultValues )
|
||||
updateDefaultValues( updatedFeature.id(), updatedFeature );
|
||||
|
||||
return !hasError;
|
||||
|
@ -907,13 +907,17 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
|
||||
|
||||
bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = 0 ) override;
|
||||
|
||||
/** Updates an existing feature. This method needs to query the datasource
|
||||
on every call. Consider using changeAttributeValue() or
|
||||
changeGeometry() instead.
|
||||
\param f Feature to update
|
||||
\returns True in case of success and False in case of error
|
||||
/**
|
||||
* Updates an existing feature. This method needs to query the datasource
|
||||
* on every call. Consider using changeAttributeValue() or
|
||||
* changeGeometry() instead. The id of the feature will be used to match
|
||||
* an existing feature.
|
||||
*
|
||||
* \param feature Feature with changed geometry or attributes.
|
||||
* \param skipDefaultValues Default values will not be updated if this is true. False by default.
|
||||
* \returns True in case of success and False in case of error
|
||||
*/
|
||||
bool updateFeature( const QgsFeature &f );
|
||||
bool updateFeature( const QgsFeature &feature, bool skipDefaultValues = false );
|
||||
|
||||
/** Insert a new vertex before the given vertex number,
|
||||
* in the given ring, item (first number is index 0), and feature
|
||||
|
Loading…
x
Reference in New Issue
Block a user