Commit: af00fab312361ba62ba52471ae6f9f34505ffd6e Author: Bastien Montagne Date: Fri Jan 24 11:26:02 2020 +0100 Branches: blender-v2.82-release https://developer.blender.org/rBaf00fab312361ba62ba52471ae6f9f34505ffd6e
IDProps: add utility to set an ID pointer IDProp value. =================================================================== M source/blender/blenkernel/BKE_idprop.h M source/blender/blenkernel/intern/idprop.c =================================================================== diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index 94c2a94d420..2b02895043f 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -83,6 +83,8 @@ void IDP_FreeString(struct IDProperty *prop) ATTR_NONNULL(); typedef void (*IDPWalkFunc)(void *userData, IDProperty *idp); +void IDP_AssignID(IDProperty *prop, ID *id, const int flag); + /*-------- Group Functions -------*/ /** Sync values from one group to another, only where they match */ diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 1125047be32..e3b27236616 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -461,6 +461,21 @@ static IDProperty *IDP_CopyID(const IDProperty *prop, const int flag) return newp; } +void IDP_AssignID(IDProperty *prop, ID *id, const int flag) +{ + BLI_assert(prop->type == IDP_ID); + + if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0 && IDP_Id(prop) != NULL) { + id_us_min(IDP_Id(prop)); + } + + prop->data.pointer = id; + + if ((flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0) { + id_us_plus(IDP_Id(prop)); + } +} + /** \} */ /* -------------------------------------------------------------------- */ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs