diff options
author | Bastien Montagne <bastien@blender.org> | 2020-09-18 16:11:31 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-09-20 17:26:39 +0300 |
commit | 8afa42b05a260eb4b77327b296e19b24b74b123b (patch) | |
tree | 45e7fc9637c0fd76676091a04e14fc098eda9bb3 /source | |
parent | 0bd736e5da6da801f8dd4ba9b4cf9bf17f2daa64 (diff) |
IDProperties: Add utils to duplicate content of one IDProp into another.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_idprop.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/idprop.c | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index e7f9ad207a1..07a82802da8 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -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, diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 189eef5e175..a3e7d8c794d 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -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! */ |