Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-12-06 02:41:45 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-12-06 02:41:45 +0300
commit062cf438ce065b477b52f72871b95bc5ee12c619 (patch)
treebe60461642c9fd68301bdcd8d2980d13f690e9ce /source
parent5ebe54f470c364ff4ea86d15198225295092963e (diff)
remove nasty hack which made StructRNA class instaces have no __dict__,
use __slots__, it seems all the parent classes need to have slots as well for this to work. all python defined srna classes are checked for this too
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/intern/bpy_rna.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index e657cfc79e2..9370ec91d37 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -2986,16 +2986,18 @@ static PyObject* pyrna_srna_ExternalType(StructRNA *srna)
if(newclass) {
PyObject *base_compare= pyrna_srna_PyBase(srna);
PyObject *bases= PyObject_GetAttrString(newclass, "__bases__");
+ //PyObject *slots= PyObject_GetAttrString(newclass, "__slots__"); // cant do this because it gets superclasses values!
+ PyObject *slots = PyDict_GetItemString(((PyTypeObject *)newclass)->tp_dict, "__slots__");
- // XXX - highly dodgy!, this stops blender from creating __dict__ in instances
- ((PyTypeObject *)newclass)->tp_dictoffset = 0;
-
- if(PyTuple_GET_SIZE(bases)) {
+ if(slots==NULL) {
+ fprintf(stderr, "pyrna_srna_ExternalType: expected class '%s' to have __slots__ defined\n\nSee bpy_types.py\n", idname);
+ newclass= NULL;
+ }
+ else if(PyTuple_GET_SIZE(bases)) {
PyObject *base= PyTuple_GET_ITEM(bases, 0);
if(base_compare != base) {
- PyLineSpit();
- fprintf(stderr, "pyrna_srna_ExternalType: incorrect subclassing of SRNA '%s'\n", idname);
+ fprintf(stderr, "pyrna_srna_ExternalType: incorrect subclassing of SRNA '%s'\nSee bpy_types.py\n", idname);
PyObSpit("Expected! ", base_compare);
newclass= NULL;
}
@@ -3038,16 +3040,12 @@ static PyObject* pyrna_srna_Subtype(StructRNA *srna)
if(!descr) descr= "(no docs)";
/* always use O not N when calling, N causes refcount errors */
- newclass = PyObject_CallFunction( (PyObject*)&PyType_Type, "s(O){ssss}", idname, py_base, "__module__","bpy.types", "__doc__",descr);
+ newclass = PyObject_CallFunction( (PyObject*)&PyType_Type, "s(O){sssss()}", idname, py_base, "__module__","bpy.types", "__doc__",descr, "__slots__");
/* newclass will now have 2 ref's, ???, probably 1 is internal since decrefing here segfaults */
/* PyObSpit("new class ref", newclass); */
if (newclass) {
-
- // XXX - highly dodgy!, this stops blender from creating __dict__ in instances
- ((PyTypeObject *)newclass)->tp_dictoffset = 0;
-
/* srna owns one, and the other is owned by the caller */
pyrna_subtype_set_rna(newclass, srna);