See #5888. Fix bug where loading type thumbnails made undo history not synced with Blender.

If a tool.Ifc.Operator updates a prop, the prop update function will
only call _after_ the operator finishes (and therefore adds an undo step
to the undo stack). If the prop update function then calls another
tool.Ifc.Operator, that will result in another "top-level" operator
call. This second operator _won't_ get added to Blender's undo history,
yet the Bonsai history / IfcOpenShell history will have another undo
step added. Yikes!

TL;DR don't call tool.Ifc.Operator from a prop update function.
This commit is contained in:
Dion Moult
2025-02-18 16:27:53 +11:00
parent 693f7c5397
commit ae76d3253d
@@ -618,7 +618,7 @@ class AlignProduct(bpy.types.Operator):
return results
class LoadTypeThumbnails(bpy.types.Operator, tool.Ifc.Operator):
class LoadTypeThumbnails(bpy.types.Operator):
bl_idname = "bim.load_type_thumbnails"
bl_label = "Load Type Thumbnails"
bl_options = {"REGISTER", "UNDO"}
@@ -626,9 +626,9 @@ class LoadTypeThumbnails(bpy.types.Operator, tool.Ifc.Operator):
limit: bpy.props.IntProperty()
offset: bpy.props.IntProperty()
def _execute(self, context):
def execute(self, context):
if bpy.app.background:
return
return {"FINISHED"}
props = tool.Model.get_model_props()
# Only process at most one paginated class at a time.