From dff9e7d1c2ee329920d09ebe9756554a2e9ab856 Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Sun, 16 Aug 2026 21:01:09 -0500 Subject: [PATCH] Don't call transform_apply on cameras in Geometry.clear_scale clear_scale routed camera, light and speaker objects into bpy.ops.object.transform_apply, which cannot act on that data. It reported "Objects have no data to transform" and left the scale untouched -- the no-op the docstring already describes when it says clearing scale has no impact on cameras. Besides the warning spam on every drawing camera update, the call is a crash vector: transform_apply resolves bpy.context from inside the temp_override, and that has been seen to segfault (EXCEPTION_ACCESS_VIOLATION in BPY_context_member_get, via ctx_wm_python_context_get) when reached from a UI-invoked operator through bim.update_representation on a drawing camera. Return early for those data types instead. Behaviour is unchanged, since the operator was already doing nothing for them. Generated with the assistance of an AI coding tool. Co-Authored-By: Claude Opus 5 --- src/bonsai/bonsai/tool/geometry.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/bonsai/bonsai/tool/geometry.py b/src/bonsai/bonsai/tool/geometry.py index 5747b76579..1f57271790 100644 --- a/src/bonsai/bonsai/tool/geometry.py +++ b/src/bonsai/bonsai/tool/geometry.py @@ -350,6 +350,15 @@ class Geometry(bonsai.core.tool.Geometry): Note that clearing scale has no impact on cameras. """ if cls.is_scaled(obj): + if isinstance(obj.data, (bpy.types.Camera, bpy.types.Light, bpy.types.Speaker)): + # object.transform_apply cannot touch this data -- it just reports + # "Objects have no data to transform" and leaves the scale alone, which + # is why the docstring says cameras are unaffected. Skipping the call + # keeps that behaviour and avoids the operator resolving bpy.context + # from inside the temp_override below, which has been seen to segfault + # (EXCEPTION_ACCESS_VIOLATION in BPY_context_member_get) when reached + # from a UI-invoked operator via bim.update_representation. + return if not obj.data: location, rotation, _ = obj.matrix_world.decompose() obj.matrix_world = Matrix.Translation(location) @ rotation.to_matrix().to_4x4()