[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29372] trunk/blender: py/rna api:

Campbell Barton ideasman42 at gmail.com
Wed Jun 9 21:31:10 CEST 2010


Revision: 29372
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29372
Author:   campbellbarton
Date:     2010-06-09 21:31:10 +0200 (Wed, 09 Jun 2010)

Log Message:
-----------
py/rna api:
- bpy.context wasnt being created from the python bpy.types.Context type defined in bpy_types.py (bpy.context.copy() failed for eg.)
- bpy.context.copy() was returning C defined methods like FloatProperty(), which are not useful in this case, removed.

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bpy_types.py
    trunk/blender/source/blender/python/intern/bpy.c

Modified: trunk/blender/release/scripts/modules/bpy_types.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy_types.py	2010-06-09 19:20:05 UTC (rev 29371)
+++ trunk/blender/release/scripts/modules/bpy_types.py	2010-06-09 19:31:10 UTC (rev 29372)
@@ -29,11 +29,14 @@
     __slots__ = ()
 
     def copy(self):
+        import types
         new_context = {}
         generic_keys = StructRNA.__dict__.keys()
         for item in dir(self):
             if item not in generic_keys:
-                new_context[item] = getattr(self, item)
+                value = getattr(self, item)
+                if type(value) != types.BuiltinMethodType:
+                    new_context[item] = getattr(self, item)
 
         return new_context
 

Modified: trunk/blender/source/blender/python/intern/bpy.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy.c	2010-06-09 19:20:05 UTC (rev 29371)
+++ trunk/blender/source/blender/python/intern/bpy.c	2010-06-09 19:31:10 UTC (rev 29372)
@@ -141,6 +141,7 @@
 void BPy_init_modules( void )
 {
 	extern BPy_StructRNA *bpy_context_module;
+	PointerRNA ctx_ptr;
 	PyObject *mod;
 
 	/* Needs to be first since this dir is needed for future modules */
@@ -181,9 +182,12 @@
 	PyModule_AddObject( mod, "app", BPY_app_struct() );
 
 	/* bpy context */
-	bpy_context_module= ( BPy_StructRNA * ) PyObject_NEW( BPy_StructRNA, &pyrna_struct_Type );
-	RNA_pointer_create(NULL, &RNA_Context, BPy_GetContext(), &bpy_context_module->ptr);
-	bpy_context_module->freeptr= 0;
+	RNA_pointer_create(NULL, &RNA_Context, BPy_GetContext(), &ctx_ptr);
+	bpy_context_module= (BPy_StructRNA *)pyrna_struct_CreatePyObject(&ctx_ptr);
+	/* odd that this is needed, 1 ref on creation and another for the module
+	 * but without we get a crash on exit */
+	Py_INCREF(bpy_context_module);
+
 	PyModule_AddObject(mod, "context", (PyObject *)bpy_context_module);
 
 	/* utility func's that have nowhere else to go */





More information about the Bf-blender-cvs mailing list