[Bf-blender-cvs] [60fba8202ce] master: Fix T91088: Assigning custom property value in python resets UI data
Hans Goudey
noreply at git.blender.org
Tue Aug 31 18:49:19 CEST 2021
Commit: 60fba8202ce4081516f7224074887327f793bfed
Author: Hans Goudey
Date: Tue Aug 31 11:49:12 2021 -0500
Branches: master
https://developer.blender.org/rB60fba8202ce4081516f7224074887327f793bfed
Fix T91088: Assigning custom property value in python resets UI data
Assigning a new value to an IDProperty with the Python API would free
the entire contents of the existing property, which unfortunately
happened to include the UI data. The fix is to extract the UI data from
the existing property before freeing its contents. An alternative
would be adding another argument to `IDP_FreePropertyContent_ex`, but
this solution is clearer and doesn't increase complexity elsewhere.
===================================================================
M source/blender/python/generic/idprop_py_api.c
===================================================================
diff --git a/source/blender/python/generic/idprop_py_api.c b/source/blender/python/generic/idprop_py_api.c
index 58a947943b1..4296474c011 100644
--- a/source/blender/python/generic/idprop_py_api.c
+++ b/source/blender/python/generic/idprop_py_api.c
@@ -714,8 +714,12 @@ bool BPy_IDProperty_Map_ValidateAndCreate(PyObject *name_obj, IDProperty *group,
prop->next = prop_exist->next;
prop->flag = prop_exist->flag;
+ /* Don't free and reset the existing property's UI data, since this only assigns a value. */
+ IDPropertyUIData *ui_data = prop_exist->ui_data;
+ prop_exist->ui_data = NULL;
IDP_FreePropertyContent(prop_exist);
*prop_exist = *prop;
+ prop_exist->ui_data = ui_data;
MEM_freeN(prop);
}
else {
More information about the Bf-blender-cvs
mailing list