Pose UI hack needed to be undone, alternate fix is needed.
Closed, ResolvedPublic


r34885 | aligorith | 2011-02-16 12:46:32 +1100 (Wed, 16 Feb 2011) | 18 lines

Ugly hack to get PoseLib UI working ok (problem mentioned in log for

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...

Index: source/blender/python/intern/bpy_rna.c
--- source/blender/python/intern/bpy_rna.c (revision 34884)
+++ source/blender/python/intern/bpy_rna.c (revision 34885)
@@ -699,6 +699,10 @@
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);




Aligorith: tested poselib UI and couldn't get it to fail. What case was this needed for exactly?

Check the attached file. Immediately after loading the file, if trying to remove the selected pose, "Pose" (unselected) gets removed instead of "Pose.002" (selected). This does not happen when this fix was applied.

I'm currently going through and checking for other cases where this sort of problem may also be occurring...

@Joshua, still cant redo this, I'm going into the pose panels "Pose Library" and pressing "-" button. this is working as expected.


I'd previously found that just reloading the file within the same Blender session and the trying again will end up masking these problems. That is, it only shows when starting Blender from scratch.

applied alternative fix r45876. closing.