diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-09-24 07:48:26 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-09-24 07:48:26 +0400 |
commit | e90ad1d9bafccadcc05cbcad5cc64d0c9940f6f9 (patch) | |
tree | 8077e12224a729460c5bfef19ff1b3dfd4d295ac | |
parent | f866de1c9f18a726029f5a16f892c5383f3e3a92 (diff) |
Annoying hack to pretend that an operator and its properties are the same, when passing an operator to an rna function argument which accepts 'AnyType', then pass the properties instead.
This means we can do operator drawing without passing self.properties as an argument.
while this check if quite specific, if this gives problems later on we should probably change operators not to try to mix an operator and its properties, it looks nice to a scripter but internally is not easy to manage.
-rw-r--r-- | release/scripts/op/io_mesh_ply/__init__.py | 8 | ||||
-rw-r--r-- | release/scripts/op/io_scene_obj/__init__.py | 1 | ||||
-rw-r--r-- | release/scripts/op/object.py | 6 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 20 |
4 files changed, 27 insertions, 8 deletions
diff --git a/release/scripts/op/io_mesh_ply/__init__.py b/release/scripts/op/io_mesh_ply/__init__.py index 18820dea549..a67afe0cc87 100644 --- a/release/scripts/op/io_mesh_ply/__init__.py +++ b/release/scripts/op/io_mesh_ply/__init__.py @@ -53,11 +53,11 @@ class ExportPLY(bpy.types.Operator, ExportHelper): layout = self.layout row = layout.row() - row.prop(self.properties, "use_modifiers") - row.prop(self.properties, "use_normals") + row.prop(self, "use_modifiers") + row.prop(self, "use_normals") row = layout.row() - row.prop(self.properties, "use_uv_coords") - row.prop(self.properties, "use_colors") + row.prop(self, "use_uv_coords") + row.prop(self, "use_colors") def menu_func(self, context): diff --git a/release/scripts/op/io_scene_obj/__init__.py b/release/scripts/op/io_scene_obj/__init__.py index 63b9e92e166..d689d849725 100644 --- a/release/scripts/op/io_scene_obj/__init__.py +++ b/release/scripts/op/io_scene_obj/__init__.py @@ -113,7 +113,6 @@ class ExportOBJ(bpy.types.Operator, ExportHelper): def execute(self, context): import io_scene_obj.export_obj - print(self.properties.keys()) return io_scene_obj.export_obj.save(self, context, **self.properties) diff --git a/release/scripts/op/object.py b/release/scripts/op/object.py index fd6235ba783..61a4478c5e4 100644 --- a/release/scripts/op/object.py +++ b/release/scripts/op/object.py @@ -67,10 +67,10 @@ class SelectPattern(bpy.types.Operator): def draw(self, context): layout = self.layout - layout.prop(self.properties, "pattern") + layout.prop(self, "pattern") row = layout.row() - row.prop(self.properties, "case_sensitive") - row.prop(self.properties, "extend") + row.prop(self, "case_sensitive") + row.prop(self, "extend") class SelectCamera(bpy.types.Operator): diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 7bb551bd504..a1aa3331249 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1065,6 +1065,26 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, ParameterList *p StructRNA *ptype= RNA_property_pointer_type(ptr, prop); int flag = RNA_property_flag(prop); + /* this is really nasty!, so we can fake the operator having direct properties eg: + * layout.prop(self, "filepath") + * ... which infact should be + * layout.prop(self.properties, "filepath") + * + * we need to do this trick. + * if the prop is not an operator type and the pyobject is an operator, use its properties in place of its self. + * + * this is so bad that its almost a good reason to do away with fake 'self.properties -> self' class mixing + * if this causes problems in the future it should be removed. + */ + if( (ptype == &RNA_AnyType) && + (BPy_StructRNA_Check(value)) && + (RNA_struct_is_a(((BPy_StructRNA *)value)->ptr.type, &RNA_Operator)) + ) { + value= PyObject_GetAttrString(value, "properties"); + value_new= value; + } + + /* if property is an OperatorProperties pointer and value is a map, forward back to pyrna_pydict_to_props */ if (RNA_struct_is_a(ptype, &RNA_OperatorProperties) && PyDict_Check(value)) { PointerRNA opptr = RNA_property_pointer_get(ptr, prop); |