- bugfix, operators were getting their properties registered twice.
authorCampbell Barton <ideasman42@gmail.com>
Thu, 9 Sep 2010 17:41:36 +0000 (17:41 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 9 Sep 2010 17:41:36 +0000 (17:41 +0000)
- operator properties are now converted into python property() class members which bypass the operator 'properties' member.
  self.properties.mysetting
 ... can now be written as ...
  self.mysetting
- fix for error reloading rigify

release/scripts/modules/bpy_types.py
release/scripts/ui/properties_data_armature_rigify.py
source/blender/makesrna/intern/rna_wm.c
source/blender/python/intern/bpy_operator_wrap.c

index b349fa0a76edabe1dc72f6c55533976d4b18e5de..d3a1a5544f5fdc97682eae836a571c662da694f9 100644 (file)
@@ -701,6 +701,14 @@ class OrderedMeta(RNAMeta):
 class Operator(StructRNA, metaclass=OrderedMeta):
     __slots__ = ()
 
+    @classmethod
+    def easy_getsets(cls):
+        def bypass_attr(attr):
+            setattr(cls, attr, property(lambda self: getattr(self.properties, attr), lambda self, value: setattr(self.properties, attr, value)))
+        for attr, value in list(cls.__dict__.items()):
+            if type(value) == tuple and len(value) == 2 and type(value[1]) == dict:
+                bypass_attr(attr)
+
 
 class Macro(StructRNA, metaclass=OrderedMeta):
     # bpy_types is imported before ops is defined
index 92b9074892bc00cd4014da35c2eb07c90408300d..3a34f8e1b9de4dfdade42341c6b521c759b59bc8 100644 (file)
@@ -318,7 +318,7 @@ def register():
 
 
 def unregister():
-    bpy.types.Scene.RemoveProperty("pose_templates")
+    del bpy.types.Scene.pose_templates
     space_info.INFO_MT_armature_add.remove(menu_func)
 
 if __name__ == "__main__":
index f4c19db1277bd6ed8310312b817cd7a03e555b2d..900a1fd60cfce4669d9e5afaf91fc02ba43dc85d 100644 (file)
@@ -840,6 +840,7 @@ static StructRNA *rna_Operator_register(const bContext *C, ReportList *reports,
 
        /* create a new menu 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 */
        dummyot.ext.data= data;
        dummyot.ext.call= call;
        dummyot.ext.free= free;
index 6d16896fb165ff5393df8f2737ab4afa2abb64ae..27da839960b77df30829388ad06d98cc04b94e46 100644 (file)
@@ -45,6 +45,9 @@ static void operator_properties_init(wmOperatorType *ot)
                PyErr_Print(); /* failed to register operator props */
                PyErr_Clear();
        }
+       
+       // see bpy_types.py:Operator, May redo this some other way!
+       PyObject_CallMethod(py_class, "easy_getsets", NULL);
 }
 
 void operator_wrapper(wmOperatorType *ot, void *userdata)