From dac8563ccfb8e38a84472e425a851be5055d0a83 Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Thu, 16 Jul 2026 12:39:47 -0500 Subject: [PATCH] Bonsai: guard change_data against a None mesh datablock reimport_element_representations' change_data already handles an empty -> mesh transition (recreate_object_with_data when the datatypes differ), but the leftover-data cleanup then called has_data_users(old_data) with old_data=None, crashing with "'NoneType' object has no attribute 'users'". Guard the cleanup so an object with no prior mesh reloads cleanly. Closes #8655 Co-Authored-By: Claude Opus 4.8 --- src/bonsai/bonsai/tool/geometry.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bonsai/bonsai/tool/geometry.py b/src/bonsai/bonsai/tool/geometry.py index 08abd38b22..d4e07de6b2 100644 --- a/src/bonsai/bonsai/tool/geometry.py +++ b/src/bonsai/bonsai/tool/geometry.py @@ -1094,7 +1094,10 @@ class Geometry(bonsai.core.tool.Geometry): else: obj = cls.recreate_object_with_data(obj, data, is_global=False) cls.record_object_materials(obj) - if not cls.has_data_users(old_data): + # old_data is None when the object had no mesh (e.g. an EMPTY being given geometry); + # recreate_object_with_data already handled that transition above, so there is nothing to + # clean up. Guard has_data_users/delete_data, which both assume a non-None datablock. + if old_data is not None and not cls.has_data_users(old_data): cls.delete_data(old_data) cls.clear_modifiers(obj) cls.clear_cache(element)