diff --git a/CHANGELOG.md b/CHANGELOG.md index d0f4f7b..67ccaba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ increasing number of samples, up to the set maximum. The total number of samples of the final render is still equal to the number of samples configured in the blend file. Requires Flamenco Server 2.2 or newer. +- Flamenco: Added a hidden "Submit & Quit" button. This button can be enabled in the add-on + preferences and and then be available on the Flamenco Render panel. Pressing the button will + silently close Blender after the job has been submitted to Flamenco (for example to click, + walk away, and free up memory for when the same machine is part of the render farm). ## Version 1.11.1 (2019-01-04) diff --git a/blender_cloud/blender.py b/blender_cloud/blender.py index 2b14b63..8f45298 100644 --- a/blender_cloud/blender.py +++ b/blender_cloud/blender.py @@ -267,6 +267,13 @@ class BlenderCloudPreferences(AddonPreferences): description='When enabled, Blender will open a webbrowser', default=True, ) + flamenco_show_quit_after_submit_button = BoolProperty( + name='Show "Submit & Quit" button', + description='When enabled, next to the "Render on Flamenco" button there will be a button ' + '"Submit & Quit" that silently quits Blender after submitting the render job ' + 'to Flamenco', + default=False, + ) def draw(self, context): import textwrap @@ -489,6 +496,7 @@ class BlenderCloudPreferences(AddonPreferences): flamenco_box.prop(self, 'flamenco_relative_only') flamenco_box.prop(self, 'flamenco_open_browser_after_submit') + flamenco_box.prop(self, 'flamenco_show_quit_after_submit_button') class PillarCredentialsUpdate(pillar.PillarOperatorMixin, diff --git a/blender_cloud/flamenco/__init__.py b/blender_cloud/flamenco/__init__.py index 2588a87..1d8872c 100644 --- a/blender_cloud/flamenco/__init__.py +++ b/blender_cloud/flamenco/__init__.py @@ -118,6 +118,19 @@ def manager_updated(self: 'FlamencoManagerGroup', context): pppm) +def silently_quit_blender(): + """Quit Blender without any confirmation popup.""" + + try: + prefs = bpy.context.preferences + except AttributeError: + # Backward compatibility with Blender < 2.80 + prefs = bpy.context.user_preferences + + prefs.view.use_quit_dialog = False + bpy.ops.wm.quit_blender() + + class FlamencoManagerGroup(PropertyGroup): manager = EnumProperty( items=available_managers, @@ -222,6 +235,8 @@ class FLAMENCO_OT_render(async_loop.AsyncModalOperatorMixin, stop_upon_exception = True log = logging.getLogger('%s.FLAMENCO_OT_render' % __name__) + quit_after_submit = BoolProperty() + async def async_execute(self, context): # Refuse to start if the file hasn't been saved. It's okay if # it's dirty, but we do need a filename and a location. @@ -395,6 +410,9 @@ class FLAMENCO_OT_render(async_loop.AsyncModalOperatorMixin, else: self.report({'INFO'}, 'Flamenco job created.') + if self.quit_after_submit: + silently_quit_blender() + self.quit() def validate_job_settings(self, context, settings: dict) -> bool: @@ -955,9 +973,17 @@ class FLAMENCO_PT_render(bpy.types.Panel, FlamencoPollMixin): # Show current status of Flamenco. flamenco_status = context.window_manager.flamenco_status if flamenco_status in {'IDLE', 'ABORTED', 'DONE'}: - layout.operator(FLAMENCO_OT_render.bl_idname, - text='Render on Flamenco', - icon='RENDER_ANIMATION') + if prefs.flamenco_show_quit_after_submit_button: + ui = paths_layout.split(**blender.factor(0.75), align=True) + else: + ui = layout + ui.operator(FLAMENCO_OT_render.bl_idname, + text='Render on Flamenco', + icon='RENDER_ANIMATION').quit_after_submit = False + if prefs.flamenco_show_quit_after_submit_button: + ui.operator(FLAMENCO_OT_render.bl_idname, + text='Submit & Quit', + icon='RENDER_ANIMATION').quit_after_submit = True if bpy.app.debug: layout.operator(FLAMENCO_OT_copy_files.bl_idname) elif flamenco_status == 'INVESTIGATING':