[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27433] branches/render25: fix for nasty bug where registering properties would register them in the parent classes SRNA , made for confusing rigify args turning up in add sequencer adding collection .
Campbell Barton
ideasman42 at gmail.com
Fri Mar 12 10:36:43 CET 2010
Revision: 27433
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27433
Author: campbellbarton
Date: 2010-03-12 10:36:42 +0100 (Fri, 12 Mar 2010)
Log Message:
-----------
fix for nasty bug where registering properties would register them in the parent classes SRNA, made for confusing rigify args turning up in add sequencer adding collection.
Modified Paths:
--------------
branches/render25/release/scripts/ui/properties_data_armature_rigify.py
branches/render25/source/blender/python/intern/bpy_operator_wrap.c
branches/render25/source/blender/python/intern/bpy_props.c
branches/render25/source/blender/python/intern/bpy_rna.c
branches/render25/source/blender/python/intern/bpy_rna.h
Modified: branches/render25/release/scripts/ui/properties_data_armature_rigify.py
===================================================================
--- branches/render25/release/scripts/ui/properties_data_armature_rigify.py 2010-03-12 08:21:09 UTC (rev 27432)
+++ branches/render25/release/scripts/ui/properties_data_armature_rigify.py 2010-03-12 09:36:42 UTC (rev 27433)
@@ -29,29 +29,7 @@
class PoseTemplate(bpy.types.IDPropertyGroup):
pass
-PoseTemplate.StringProperty(attr="name",
- name="Name of the slave",
- description="",
- maxlen=64,
- default="")
-
-PoseTemplateSettings.CollectionProperty(attr="templates", type=PoseTemplate, name="Templates", description="")
-PoseTemplateSettings.IntProperty(attr="active_template_index",
- name="Index of the active slave",
- description="",
- default=-1,
- min=-1,
- max=65535)
-
-PoseTemplateSettings.BoolProperty(attr="generate_def_rig",
- name="Create Deform Rig",
- description="Create a copy of the metarig, constrainted by the generated rig",
- default=False)
-
-bpy.types.Scene.PointerProperty(attr="pose_templates", type=PoseTemplateSettings, name="Pose Templates", description="Pose Template Settings")
-
-
def metarig_templates():
import rigify
return rigify.get_submodule_types()
@@ -356,6 +334,28 @@
for cls in classes:
register(cls)
+ PoseTemplate.StringProperty(attr="name",
+ name="Name of the slave",
+ description="",
+ maxlen=64,
+ default="")
+
+
+ PoseTemplateSettings.CollectionProperty(attr="templates", type=PoseTemplate, name="Templates", description="")
+ PoseTemplateSettings.IntProperty(attr="active_template_index",
+ name="Index of the active slave",
+ description="",
+ default=-1,
+ min=-1,
+ max=65535)
+
+ PoseTemplateSettings.BoolProperty(attr="generate_def_rig",
+ name="Create Deform Rig",
+ description="Create a copy of the metarig, constrainted by the generated rig",
+ default=False)
+
+ bpy.types.Scene.PointerProperty(attr="pose_templates", type=PoseTemplateSettings, name="Pose Templates", description="Pose Template Settings")
+
space_info.INFO_MT_armature_add.append(menu_func)
Modified: branches/render25/source/blender/python/intern/bpy_operator_wrap.c
===================================================================
--- branches/render25/source/blender/python/intern/bpy_operator_wrap.c 2010-03-12 08:21:09 UTC (rev 27432)
+++ branches/render25/source/blender/python/intern/bpy_operator_wrap.c 2010-03-12 09:36:42 UTC (rev 27433)
@@ -114,7 +114,7 @@
}
/* identifiers */
- srna= srna_from_self(macro);
+ srna= srna_from_self(macro, "Macro Define:");
macroname = RNA_struct_identifier(srna);
ot = WM_operatortype_exists(macroname);
Modified: branches/render25/source/blender/python/intern/bpy_props.c
===================================================================
--- branches/render25/source/blender/python/intern/bpy_props.c 2010-03-12 08:21:09 UTC (rev 27432)
+++ branches/render25/source/blender/python/intern/bpy_props.c 2010-03-12 09:36:42 UTC (rev 27433)
@@ -118,7 +118,7 @@
return NULL;
}
- srna= srna_from_self(self);
+ srna= srna_from_self(self, "BoolProperty(...):");
if(srna==NULL && PyErr_Occurred()) {
return NULL; /* self's type was compatible but error getting the srna */
}
@@ -184,7 +184,7 @@
return NULL;
}
- srna= srna_from_self(self);
+ srna= srna_from_self(self, "BoolVectorProperty(...):");
if(srna==NULL && PyErr_Occurred()) {
return NULL; /* self's type was compatible but error getting the srna */
}
@@ -261,7 +261,7 @@
return NULL;
}
- srna= srna_from_self(self);
+ srna= srna_from_self(self, "IntProperty(...):");
if(srna==NULL && PyErr_Occurred()) {
return NULL; /* self's type was compatible but error getting the srna */
}
@@ -328,7 +328,7 @@
return NULL;
}
- srna= srna_from_self(self);
+ srna= srna_from_self(self, "IntVectorProperty(...):");
if(srna==NULL && PyErr_Occurred()) {
return NULL; /* self's type was compatible but error getting the srna */
}
@@ -409,7 +409,7 @@
return NULL;
}
- srna= srna_from_self(self);
+ srna= srna_from_self(self, "FloatProperty(...):");
if(srna==NULL && PyErr_Occurred()) {
return NULL; /* self's type was compatible but error getting the srna */
}
@@ -484,7 +484,7 @@
return NULL;
}
- srna= srna_from_self(self);
+ srna= srna_from_self(self, "FloatVectorProperty(...):");
if(srna==NULL && PyErr_Occurred()) {
return NULL; /* self's type was compatible but error getting the srna */
}
@@ -562,7 +562,7 @@
return NULL;
}
- srna= srna_from_self(self);
+ srna= srna_from_self(self, "StringProperty(...):");
if(srna==NULL && PyErr_Occurred()) {
return NULL; /* self's type was compatible but error getting the srna */
}
@@ -674,7 +674,7 @@
return NULL;
}
- srna= srna_from_self(self);
+ srna= srna_from_self(self, "EnumProperty(...):");
if(srna==NULL && PyErr_Occurred()) {
return NULL; /* self's type was compatible but error getting the srna */
}
@@ -719,18 +719,22 @@
}
}
-static StructRNA *pointer_type_from_py(PyObject *value)
+static StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix)
{
StructRNA *srna;
- srna= srna_from_self(value);
+ srna= srna_from_self(value, "BoolProperty(...):");
if(!srna) {
- PyErr_SetString(PyExc_SystemError, "expected an RNA type derived from IDPropertyGroup");
+
+ PyObject *msg= BPY_exception_buffer();
+ char *msg_char= _PyUnicode_AsString(msg);
+ PyErr_Format(PyExc_TypeError, "%.200s expected an RNA type derived from IDPropertyGroup, failed with: %s", error_prefix, msg_char);
+ Py_DECREF(msg);
return NULL;
}
if(!RNA_struct_is_a(srna, &RNA_IDPropertyGroup)) {
- PyErr_SetString(PyExc_SystemError, "expected an RNA type derived from IDPropertyGroup");
+ PyErr_Format(PyExc_SystemError, "%.200s expected an RNA type derived from IDPropertyGroup", error_prefix);
return NULL;
}
@@ -755,7 +759,7 @@
return NULL;
}
- srna= srna_from_self(self);
+ srna= srna_from_self(self, "PointerProperty(...):");
if(srna==NULL && PyErr_Occurred()) {
return NULL; /* self's type was compatible but error getting the srna */
}
@@ -780,7 +784,7 @@
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "PointerProperty(options={...}):"))
return NULL;
- ptype= pointer_type_from_py(type);
+ ptype= pointer_type_from_py(type, "PointerProperty(...):");
if(!ptype)
return NULL;
@@ -816,7 +820,7 @@
return NULL;
}
- srna= srna_from_self(self);
+ srna= srna_from_self(self, "CollectionProperty(...):");
if(srna==NULL && PyErr_Occurred()) {
return NULL; /* self's type was compatible but error getting the srna */
}
@@ -841,7 +845,7 @@
if(pyopts && pyrna_set_to_enum_bitfield(property_flag_items, pyopts, &opts, "CollectionProperty(options={...}):"))
return NULL;
- ptype= pointer_type_from_py(type);
+ ptype= pointer_type_from_py(type, "CollectionProperty(...):");
if(!ptype)
return NULL;
Modified: branches/render25/source/blender/python/intern/bpy_rna.c
===================================================================
--- branches/render25/source/blender/python/intern/bpy_rna.c 2010-03-12 08:21:09 UTC (rev 27432)
+++ branches/render25/source/blender/python/intern/bpy_rna.c 2010-03-12 09:36:42 UTC (rev 27433)
@@ -3541,26 +3541,6 @@
}
}
-/*
-static StructRNA *srna_from_self(PyObject *self);
-PyObject *BPy_GetStructRNA(PyObject *self)
-{
- StructRNA *srna= pyrna_struct_as_srna(self);
- PointerRNA ptr;
- PyObject *ret;
-
- RNA_pointer_create(NULL, &RNA_Struct, srna, &ptr);
- ret= pyrna_struct_CreatePyObject(&ptr);
-
- if(ret) {
- return ret;
- }
- else {
- Py_RETURN_NONE;
- }
-}
-*/
-
static PyObject* pyrna_srna_Subtype(StructRNA *srna);
/* return a borrowed reference */
@@ -3901,7 +3881,7 @@
return (PyObject *)self;
}
-StructRNA *pyrna_struct_as_srna(PyObject *self)
+StructRNA *pyrna_struct_as_srna(PyObject *self, int parent, const char *error_prefix)
{
BPy_StructRNA *py_srna = NULL;
StructRNA *srna;
@@ -3911,23 +3891,27 @@
py_srna = (BPy_StructRNA *)PyDict_GetItemString(((PyTypeObject *)self)->tp_dict, "bl_rna");
Py_XINCREF(py_srna);
}
-
- if(py_srna==NULL)
- py_srna = (BPy_StructRNA*)PyObject_GetAttrString(self, "bl_rna");
+ if(parent) {
+ /* be very careful with this since it will return a parent classes srna.
+ * modifying this will do confusing stuff! */
+ if(py_srna==NULL)
+ py_srna = (BPy_StructRNA*)PyObject_GetAttrString(self, "bl_rna");
+ }
+
if(py_srna==NULL) {
- PyErr_SetString(PyExc_SystemError, "internal error, self had no bl_rna attribute, should never happen.");
+ PyErr_Format(PyExc_SystemError, "%.200s internal error, self of type '%.200s' had no bl_rna attribute, should never happen", error_prefix, Py_TYPE(self)->tp_name);
return NULL;
}
if(!BPy_StructRNA_Check(py_srna)) {
- PyErr_Format(PyExc_SystemError, "internal error, bl_rna was of type %.200s, instead of %.200s instance.", Py_TYPE(py_srna)->tp_name, pyrna_struct_Type.tp_name);
+ PyErr_Format(PyExc_SystemError, "%.200s internal error, bl_rna was of type '%.200s', instead of %.200s instance", error_prefix, Py_TYPE(py_srna)->tp_name, pyrna_struct_Type.tp_name);
Py_DECREF(py_srna);
return NULL;
}
if(py_srna->ptr.type != &RNA_Struct) {
- PyErr_SetString(PyExc_SystemError, "internal error, bl_rna was not a RNA_Struct type of rna struct.");
+ PyErr_Format(PyExc_SystemError, "%.200s internal error, bl_rna was not a RNA_Struct type of rna struct", error_prefix);
Py_DECREF(py_srna);
return NULL;
}
@@ -3941,7 +3925,7 @@
/* Orphan functions, not sure where they should go */
/* get the srna for methods attached to types */
/* */
-StructRNA *srna_from_self(PyObject *self)
+StructRNA *srna_from_self(PyObject *self, const char *error_prefix)
{
/* a bit sloppy but would cause a very confusing bug if
* an error happened to be set here */
@@ -3959,7 +3943,7 @@
/* These cases above not errors, they just mean the type was not compatible
* After this any errors will be raised in the script */
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list