[Bf-blender-cvs] [8afa42b05a2] master: IDProperties: Add utils to duplicate content of one IDProp into another.
Bastien Montagne
noreply at git.blender.org
Sun Sep 20 17:00:31 CEST 2020
Commit: 8afa42b05a260eb4b77327b296e19b24b74b123b
Author: Bastien Montagne
Date: Fri Sep 18 15:11:31 2020 +0200
Branches: master
https://developer.blender.org/rB8afa42b05a260eb4b77327b296e19b24b74b123b
IDProperties: Add utils to duplicate content of one IDProp into another.
===================================================================
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 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! */
More information about the Bf-blender-cvs
mailing list