IDProps: add utility to set an ID pointer IDProp value.

This commit is contained in:
Bastien Montagne 2020-01-24 11:26:02 +01:00
parent 005af1e274
commit af00fab312
2 changed files with 17 additions and 0 deletions

View File

@ -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 */

View File

@ -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));
}
}
/** \} */
/* -------------------------------------------------------------------- */