IDProps: add utility to set an ID pointer IDProp value.
This commit is contained in:
parent
005af1e274
commit
af00fab312
|
@ -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 */
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
|
Loading…
Reference in New Issue