IDProperties: Add utils to duplicate content of one IDProp into another.

This commit is contained in:
Bastien Montagne 2020-09-18 15:11:31 +02:00
parent 0bd736e5da
commit 8afa42b05a
2 changed files with 14 additions and 0 deletions

View File

@ -127,6 +127,7 @@ struct IDProperty *IDP_CopyProperty(const struct IDProperty *prop) ATTR_WARN_UNU
ATTR_NONNULL();
struct IDProperty *IDP_CopyProperty_ex(const struct IDProperty *prop,
const int flag) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
void IDP_CopyPropertyContent(IDProperty *dst, IDProperty *src) ATTR_NONNULL();
bool IDP_EqualsProperties_ex(IDProperty *prop1,
IDProperty *prop2,

View File

@ -787,6 +787,19 @@ IDProperty *IDP_CopyProperty(const IDProperty *prop)
return IDP_CopyProperty_ex(prop, 0);
}
/**
* Copy content from source IDProperty into destination one, freeing destination property's content
* first.
*/
void IDP_CopyPropertyContent(IDProperty *dst, IDProperty *src)
{
IDProperty *idprop_tmp = IDP_CopyProperty(src);
idprop_tmp->prev = dst->prev;
idprop_tmp->next = dst->next;
SWAP(IDProperty, *dst, *idprop_tmp);
IDP_FreeProperty(idprop_tmp);
}
/* Updates ID pointers after an object has been copied */
/* TODO Nuke this once its only user has been correctly converted
* to use generic ID management from BKE_library! */