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 <noreply@anthropic.com>
This commit is contained in:
Ryan Schultz
2026-07-16 12:39:47 -05:00
parent 1c421d01c3
commit dac8563ccf
+4 -1
View File
@@ -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)