[Bf-blender-cvs] [56a336196db] blender2.8: Add utility function to reset ID property value to a given one

Sergey Sharybin noreply at git.blender.org
Wed Jan 24 15:05:44 CET 2018


Commit: 56a336196dbd9d63e84ae8e0cb92b11b211dde6e
Author: Sergey Sharybin
Date:   Wed Jan 24 15:00:01 2018 +0100
Branches: blender2.8
https://developer.blender.org/rB56a336196dbd9d63e84ae8e0cb92b11b211dde6e

Add utility function to reset ID property value to a given one

This is similar to idproperty_reset() defined in layer.c, but it does not
re-alloc property itself.

We should replace idproperty_reset() with IDP_Reset() now.

===================================================================

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 055c530d255..02912739e86 100644
--- a/source/blender/blenkernel/BKE_idprop.h
+++ b/source/blender/blenkernel/BKE_idprop.h
@@ -32,6 +32,10 @@
 
 #include "BLI_compiler_attrs.h"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct IDProperty;
 struct ID;
 
@@ -119,6 +123,8 @@ void IDP_ClearProperty(IDProperty *prop);
 
 void IDP_RelinkProperty(struct IDProperty *prop);
 
+void IDP_Reset(IDProperty *prop, const IDProperty *reference);
+
 #define IDP_Int(prop)                     ((prop)->data.val)
 #define IDP_Array(prop)                   ((prop)->data.pointer)
 /* C11 const correctness for casts */
@@ -151,4 +157,8 @@ void IDP_RelinkProperty(struct IDProperty *prop);
 void IDP_spit(IDProperty *prop);
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __BKE_IDPROP_H__ */
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index b00a62a1a87..33a665ba06e 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -1094,4 +1094,15 @@ void IDP_ClearProperty(IDProperty *prop)
 	prop->len = prop->totallen = 0;
 }
 
+void IDP_Reset(IDProperty *prop, const IDProperty *reference)
+{
+	if (prop == NULL) {
+		return;
+	}
+	IDP_ClearProperty(prop);
+	if (reference != NULL) {
+		IDP_MergeGroup(prop, reference, true);
+	}
+}
+
 /** \} */



More information about the Bf-blender-cvs mailing list