[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34885] trunk/blender/source/blender/ python/intern/bpy_rna.c: Ugly hack to get PoseLib UI working ok ( problem mentioned in log for

Joshua Leung aligorith at gmail.com
Wed Feb 16 02:46:33 CET 2011


Revision: 34885
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34885
Author:   aligorith
Date:     2011-02-16 01:46:32 +0000 (Wed, 16 Feb 2011)
Log Message:
-----------
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...

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34883

Modified Paths:
--------------
    trunk/blender/source/blender/python/intern/bpy_rna.c

Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c	2011-02-16 00:19:54 UTC (rev 34884)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c	2011-02-16 01:46:32 UTC (rev 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);




More information about the Bf-blender-cvs mailing list