From ae76d3253d396e053e12e139e74e16482ea3e157 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 18 Feb 2025 16:27:53 +1100 Subject: [PATCH] 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. --- src/bonsai/bonsai/bim/module/model/product.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/model/product.py b/src/bonsai/bonsai/bim/module/model/product.py index 06ae1a4fa0..ddc9eb5fea 100644 --- a/src/bonsai/bonsai/bim/module/model/product.py +++ b/src/bonsai/bonsai/bim/module/model/product.py @@ -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.