From a833064fc18a12ab8f1595910764590b2ec363f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 20 Jun 2022 18:08:44 +0200 Subject: [PATCH] Addon: fix issue where invisible settings were not evaluated on submission The code was still using the old `visible: true/false` approach, which was replaced with a visibility string. The GUI and job submission code now use the same function to determine visibility. --- addon/flamenco/gui.py | 13 ++----------- addon/flamenco/job_types.py | 11 +++++++++++ addon/flamenco/job_types_propgroup.py | 4 +++- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/addon/flamenco/gui.py b/addon/flamenco/gui.py index 47577b98..720f0ec1 100644 --- a/addon/flamenco/gui.py +++ b/addon/flamenco/gui.py @@ -3,7 +3,7 @@ from typing import Optional, TYPE_CHECKING -from . import preferences +from . import preferences, job_types from .job_types_propgroup import JobTypePropertyGroup import bpy @@ -85,7 +85,7 @@ class FLAMENCO_PT_job_submission(bpy.types.Panel): propgroup: JobTypePropertyGroup, setting: _AvailableJobSetting, ) -> None: - if not self.setting_is_visible(setting): + if not job_types.setting_is_visible(setting): return row = layout.row(align=True) @@ -102,15 +102,6 @@ class FLAMENCO_PT_job_submission(bpy.types.Panel): op = row.operator("flamenco3.explore_file_path", text="", icon="WINDOW") op.path = getattr(propgroup, setting.key) - @staticmethod - def setting_is_visible(setting: _AvailableJobSetting) -> bool: - try: - visibility = setting.visible - except AttributeError: - # The default is 'visible'. - return True - return str(visibility) in {"visible", "submission"} - def draw_setting_editable( self, layout: bpy.types.UILayout, diff --git a/addon/flamenco/job_types.py b/addon/flamenco/job_types.py index 038231fc..26210772 100644 --- a/addon/flamenco/job_types.py +++ b/addon/flamenco/job_types.py @@ -13,6 +13,7 @@ _log = logging.getLogger(__name__) if TYPE_CHECKING: from flamenco.manager import ApiClient as _ApiClient from flamenco.manager.models import ( + AvailableJobSetting as _AvailableJobSetting, AvailableJobType as _AvailableJobType, AvailableJobTypes as _AvailableJobTypes, SubmittedJob as _SubmittedJob, @@ -20,6 +21,7 @@ if TYPE_CHECKING: ) else: _ApiClient = object + _AvailableJobSetting = object _AvailableJobType = object _AvailableJobTypes = object _JobSettings = object @@ -57,6 +59,15 @@ def fetch_available_job_types(api_client: _ApiClient, scene: bpy.types.Scene) -> _store_available_job_types(response) +def setting_is_visible(setting: _AvailableJobSetting) -> bool: + try: + visibility = setting.visible + except AttributeError: + # The default is 'visible'. + return True + return str(visibility) in {"visible", "submission"} + + def _store_available_job_types(available_job_types: _AvailableJobTypes) -> None: global _available_job_types global _job_type_enum_items diff --git a/addon/flamenco/job_types_propgroup.py b/addon/flamenco/job_types_propgroup.py index b23f0191..97ae9eb9 100644 --- a/addon/flamenco/job_types_propgroup.py +++ b/addon/flamenco/job_types_propgroup.py @@ -9,6 +9,8 @@ from typing import TYPE_CHECKING, Callable, Optional, Any, Union import bpy +from . import job_types + _log = logging.getLogger(__name__) if TYPE_CHECKING: @@ -124,7 +126,7 @@ class JobTypePropertyGroup: setting value. Otherwise the default is used. """ for setting in self.job_type.settings: - if setting.get("visible", True): + if job_types.setting_is_visible(setting): # Skip those settings that will be visible in the GUI. continue