diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_idprop.h | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/idprop.c | 15 |
2 files changed, 22 insertions, 4 deletions
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index 027f06ef84f..2dd1bfc2a51 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -266,6 +266,12 @@ __attribute__((nonnull)) #endif ; +int IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const int is_strict) +#ifdef __GNUC__ +__attribute__((warn_unused_result)) +#endif +; + int IDP_EqualsProperties(struct IDProperty *prop1, struct IDProperty *prop2) #ifdef __GNUC__ __attribute__((warn_unused_result)) @@ -319,4 +325,9 @@ void IDP_UnlinkProperty(struct IDProperty *prop); #define IDP_IDPArray(prop) ((IDProperty *)(prop)->data.pointer) #define IDP_Double(prop) (*(double *)&(prop)->data.val) +#ifdef DEBUG +/* for printout only */ +void IDP_spit(IDProperty *prop); +#endif + #endif /* __BKE_IDPROP_H__ */ diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 584de4cd982..5dd0f08dc71 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -632,12 +632,14 @@ IDProperty *IDP_GetProperties(ID *id, int create_if_needed) } } -int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) +/** + * \param is_strict When FALSE treat missing items as a match */ +int IDP_EqualsProperties_ex(IDProperty *prop1, IDProperty *prop2, const int is_strict) { if (prop1 == NULL && prop2 == NULL) return 1; else if (prop1 == NULL || prop2 == NULL) - return 0; + return is_strict ? 0 : 1; else if (prop1->type != prop2->type) return 0; @@ -661,13 +663,13 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) { IDProperty *link1, *link2; - if (BLI_countlist(&prop1->data.group) != BLI_countlist(&prop2->data.group)) + if (is_strict && BLI_countlist(&prop1->data.group) != BLI_countlist(&prop2->data.group)) return 0; for (link1 = prop1->data.group.first; link1; link1 = link1->next) { link2 = IDP_GetPropertyFromGroup(prop2, link1->name); - if (!IDP_EqualsProperties(link1, link2)) + if (!IDP_EqualsProperties_ex(link1, link2, is_strict)) return 0; } @@ -696,6 +698,11 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) return 1; } +int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) +{ + return IDP_EqualsProperties_ex(prop1, prop2, TRUE); +} + /* 'val' is never NULL, don't check */ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name) { |