[#24491] not possible to create a new Rendering preset than "add render preset.py"
authorCampbell Barton <ideasman42@gmail.com>
Mon, 1 Nov 2010 21:07:25 +0000 (21:07 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 1 Nov 2010 21:07:25 +0000 (21:07 +0000)
- Setting operator properties was broken because of bpy_types.py meta-classing (surprising this wasn't noticed before!)
- Presets now use a dialog with an OK button.
- Presets use a check function on the filename so invalid chars are replaced editing.
- Submit docs operator was broken.

release/scripts/modules/bpy_types.py
release/scripts/op/presets.py
release/scripts/op/wm.py

index 6ecb8a2e207fbc8f4ee6d0913da7328a974b4e42..472fae59abe50a5decb554662e5820c66204611a 100644 (file)
@@ -650,14 +650,14 @@ class Operator(StructRNA, metaclass=OrderedMeta):
         properties = StructRNA.path_resolve(self, "properties")
         bl_rna = getattr(properties, "bl_rna", None)
         if bl_rna and attr in bl_rna.properties:
-            setattr(properties, attr, value)
+            return setattr(properties, attr, value)
         return super().__setattr__(attr, value)
 
     def __delattr__(self, attr):
         properties = StructRNA.path_resolve(self, "properties")
         bl_rna = getattr(properties, "bl_rna", None)
         if bl_rna and attr in bl_rna.properties:
-            delattr(properties, attr)
+            return delattr(properties, attr)
         return super().__delattr__(attr)
 
 
index ec14e305c51fd1ae47fee1c10f6589e6b7c59542..3a78f15d7704df73c2ab98d42da70ab8b703babc 100644 (file)
@@ -54,7 +54,7 @@ class AddPresetBase():
                 return {'FINISHED'}
 
             filename = self.as_filename(self.name)
-            
+
             target_path = bpy.utils.preset_paths(self.preset_subdir)[0]  # we need some way to tell the user and system preset path
 
             filepath = os.path.join(target_path, filename) + ".py"
@@ -76,8 +76,8 @@ class AddPresetBase():
                     file_preset.write("%s = %r\n" % (rna_path, value))
 
                 file_preset.close()
-            
-            preset_menu_class.bl_label = bpy.path.display_name(self.name)
+
+            preset_menu_class.bl_label = bpy.path.display_name(filename)
 
         else:
             preset_active = preset_menu_class.bl_label
@@ -108,10 +108,13 @@ class AddPresetBase():
 
         return {'FINISHED'}
 
+    def check(self, context):
+        self.name = self.as_filename(self.name)
+
     def invoke(self, context, event):
         if not self.remove_active:
             wm = context.window_manager
-            return wm.invoke_props_popup(self, event)
+            return wm.invoke_props_dialog(self)
         else:
             return self.execute(context)
 
index ca1ed6ed168cf3b441411b0fc310a1a410024656..9827c93f218df065dd0d3bca16c7d5287e8d108f 100644 (file)
@@ -632,7 +632,7 @@ class WM_OT_doc_edit(bpy.types.Operator):
 
     def draw(self, context):
         layout = self.layout
-        layout.label(text="Descriptor ID: '%s'" % props.doc_id)
+        layout.label(text="Descriptor ID: '%s'" % self.doc_id)
         layout.prop(self, "doc_new", text="")
 
     def invoke(self, context, event):