Addon: gracefully handle disappearing job type
When refreshing the list of available job types, Blender recreates the job type property itself, clearing out any previously chosen value. The add-on tries to restore that previously chosen value, and now also gracefully handles the case where this job type is no longer available.
This commit is contained in:
parent
7c99a2c000
commit
1a4e0c36e4
@ -76,8 +76,19 @@ class FLAMENCO_OT_fetch_job_types(FlamencoOpMixin, bpy.types.Operator):
|
|||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
|
|
||||||
if old_job_type_name:
|
if old_job_type_name:
|
||||||
# TODO: handle cases where the old job type no longer exists.
|
try:
|
||||||
scene.flamenco_job_type = old_job_type_name
|
scene.flamenco_job_type = old_job_type_name
|
||||||
|
except TypeError: # Thrown when the old job type no longer exists.
|
||||||
|
# You cannot un-set an enum property, and 'empty string' is not
|
||||||
|
# a valid value either, so better to just remove the underlying
|
||||||
|
# ID property.
|
||||||
|
del scene["flamenco_job_type"]
|
||||||
|
|
||||||
|
self.report(
|
||||||
|
{"WARNING"},
|
||||||
|
"Job type %r no longer available, choose another one"
|
||||||
|
% old_job_type_name,
|
||||||
|
)
|
||||||
|
|
||||||
job_types.update_job_type_properties(scene)
|
job_types.update_job_type_properties(scene)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user