diff options
author | Joshua Leung <aligorith@gmail.com> | 2011-02-16 04:46:32 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2011-02-16 04:46:32 +0300 |
commit | f5217afd1836c3fc34e0c8220d5f230295c456da (patch) | |
tree | fa98e6f3181bd3d27bbe73504287e83f9d05791c | |
parent | c39aba0f82148eed378218e8994d2edf75f2b7cb (diff) |
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...
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 4 |
1 files changed, 4 insertions, 0 deletions
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); |