[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43835] trunk/blender/source/blender: fix [#29666] Duplicate entries in bpy.types
Campbell Barton
ideasman42 at gmail.com
Thu Feb 2 05:43:45 CET 2012
Revision: 43835
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43835
Author: campbellbarton
Date: 2012-02-02 04:43:35 +0000 (Thu, 02 Feb 2012)
Log Message:
-----------
fix [#29666] Duplicate entries in bpy.types
Python operator subclasses and operator types each get their own SRNA, causing double ups for bpy.types.__dir__()
>From the operator type - these share names.
* ot->ext.srna
* ot->srna
Note that this conflict is still there, this only disables 'ot->ext.srna' from being included in dir(bpy.types).
Modified Paths:
--------------
trunk/blender/source/blender/makesrna/intern/rna_wm.c
trunk/blender/source/blender/python/intern/bpy_rna.c
Modified: trunk/blender/source/blender/makesrna/intern/rna_wm.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_wm.c 2012-02-02 01:07:04 UTC (rev 43834)
+++ trunk/blender/source/blender/makesrna/intern/rna_wm.c 2012-02-02 04:43:35 UTC (rev 43835)
@@ -1050,6 +1050,9 @@
rna_Operator_unregister(bmain, ot->ext.srna);
}
+ /* XXX, this doubles up with the operator name [#29666]
+ * for now just remove from dir(bpy.types) */
+
/* create a new operator type */
dummyot.ext.srna= RNA_def_struct(&BLENDER_RNA, dummyot.idname, "Operator");
RNA_def_struct_flag(dummyot.ext.srna, STRUCT_NO_IDPROPERTIES); /* operator properties are registered separately */
@@ -1126,7 +1129,10 @@
rna_Operator_unregister(bmain, ot->ext.srna);
}
- /* create a new menu type */
+ /* XXX, this doubles up with the operator name [#29666]
+ * for now just remove from dir(bpy.types) */
+
+ /* create a new operator type */
dummyot.ext.srna= RNA_def_struct(&BLENDER_RNA, dummyot.idname, "Operator");
dummyot.ext.data= data;
dummyot.ext.call= call;
Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c 2012-02-02 01:07:04 UTC (rev 43834)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c 2012-02-02 04:43:35 UTC (rev 43835)
@@ -6298,6 +6298,8 @@
{NULL, NULL, 0, NULL}
};
+/* used to call ..._keys() direct, but we need to filter out operator subclasses */
+#if 0
static PyObject *pyrna_basetype_dir(BPy_BaseTypeRNA *self)
{
PyObject *list;
@@ -6318,6 +6320,34 @@
return list;
}
+#else
+
+static PyObject *pyrna_basetype_dir(BPy_BaseTypeRNA *self)
+{
+ PyObject *ret = PyList_New(0);
+ PyObject *item;
+
+ RNA_PROP_BEGIN(&self->ptr, itemptr, self->prop) {
+ StructRNA *srna = itemptr.data;
+ StructRNA *srna_base = RNA_struct_base(itemptr.data);
+ /* skip own operators, these double up [#29666] */
+ if (srna_base == &RNA_Operator) {
+ /* do nothing */
+ }
+ else {
+ /* add to python list */
+ item = PyUnicode_FromString(RNA_struct_identifier(srna));
+ PyList_Append(ret, item);
+ Py_DECREF(item);
+ }
+ }
+ RNA_PROP_END;
+
+ return ret;
+}
+
+#endif
+
static PyTypeObject pyrna_basetype_Type = BLANK_PYTHON_TYPE;
PyObject *BPY_rna_types(void)
More information about the Bf-blender-cvs
mailing list