From f5217afd1836c3fc34e0c8220d5f230295c456da Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 16 Feb 2011 01:46:32 +0000 Subject: Ugly hack to get PoseLib UI working ok (problem mentioned in log for r34883). Full description: When defining an operator button in the UI layout code, trying to set the value for such an operator's enum properties, where said enum uses a dynamically generated list of items (which depends on using context info), will "fail". No context info will be passed to the callbacks used to generate this list of items, as PROP_ENUM_NO_CONTEXT is still set on the operator properties (it seems these will only get cleared when the operator actually runs, which is far too late already for this usage) so RNA_property_enum_items() will pass NULL instead of a context pointer *even* when one exists! I'm not sure of why we even need this flag. It seems to have caused a few other rounds of problems already, from quick searches I did on this matter... --- source/blender/python/intern/bpy_rna.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/python') diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index ea461a4675e..da0738375a0 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -699,6 +699,10 @@ static int pyrna_string_to_enum(PyObject *item, PointerRNA *ptr, PropertyRNA *pr MEM_freeN((void *)enum_str); return 0; } else { + /* hack so that dynamic enums used for operator properties will be able to be built (i.e. context will be supplied to itemf) + * and thus running defining operator buttons for such operators in UI will work */ + RNA_def_property_clear_flag(prop, PROP_ENUM_NO_CONTEXT); + if (!RNA_property_enum_value(BPy_GetContext(), ptr, prop, param, val)) { const char *enum_str= pyrna_enum_as_string(ptr, prop); PyErr_Format(PyExc_TypeError, "%.200s enum \"%.200s\" not found in (%.200s)", error_prefix, param, enum_str); -- cgit v1.2.3