From 1056699e4a9c20ccf67110c59aab3769ecaf435c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 25 Jun 2024 17:49:06 +0200 Subject: [PATCH] Add-on: prevent potentially crashing Blender Prevent a potential crash of Blender. Calling `context.window_manager.modal_handler_add(self)` from an operator that does not actually run modally can cause problems. So now that's called only when running modally. --- addon/flamenco/operators.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addon/flamenco/operators.py b/addon/flamenco/operators.py index 31760796..6d21672d 100644 --- a/addon/flamenco/operators.py +++ b/addon/flamenco/operators.py @@ -162,6 +162,8 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator): is_running = self._submit_files(context, filepath) if not is_running: return {"CANCELLED"} + + context.window_manager.modal_handler_add(self) return {"RUNNING_MODAL"} def modal(self, context: bpy.types.Context, event: bpy.types.Event) -> set[str]: @@ -383,7 +385,6 @@ class FLAMENCO_OT_submit_job(FlamencoOpMixin, bpy.types.Operator): self._quit(context) return False - context.window_manager.modal_handler_add(self) wm = context.window_manager self.timer = wm.event_timer_add(self.TIMER_PERIOD, window=context.window)