Skip to content

Commit f311188

Browse files
Fix an issue in blender 4.0 when deleting objects in viewport
1 parent 066c431 commit f311188

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

bseq/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@
1212
@persistent
1313
def BSEQ_initialize(scene):
1414
if update_obj not in bpy.app.handlers.frame_change_post:
15+
bpy.app.handlers.frame_change_post.append(update_obj)
16+
if auto_refresh_active not in bpy.app.handlers.frame_change_post:
1517
bpy.app.handlers.frame_change_post.append(auto_refresh_active)
18+
if auto_refresh_all not in bpy.app.handlers.frame_change_post:
1619
bpy.app.handlers.frame_change_post.append(auto_refresh_all)
17-
bpy.app.handlers.frame_change_post.append(update_obj)
20+
if clean_unused_bseq_data not in bpy.app.handlers.save_pre:
21+
bpy.app.handlers.save_pre.append(clean_unused_bseq_data)
1822
subscribe_to_selected()
1923
if print_information not in bpy.app.handlers.render_init:
2024
bpy.app.handlers.render_init.append(print_information)

bseq/globals.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,14 @@ def auto_refresh_active(scene, depsgraph=None):
5151
continue
5252
if obj.mode != "OBJECT":
5353
continue
54-
refresh_obj(obj, scene)
54+
refresh_obj(obj, scene)
55+
56+
# This becomes necessary, because when deleting objects from the viewport, they dont actually get removed from the
57+
# sequences list, because this is not a global delete. This handler only removes sequences that are not referenced
58+
# in any scene or collection. This handler is added to save_pre, so that unused data blocks dont get saved
59+
def clean_unused_bseq_data(savefile):
60+
for obj in bpy.data.objects:
61+
if obj.BSEQ.init and len(obj.users_collection)==0 and len(obj.users_scene)==0:
62+
63+
# This will throw an error if it is actually still used somewhere
64+
bpy.data.objects.remove(obj)

bseq/panels.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def filter_items(self, context, data, property):
1313
# not sure if I understand correctly about this
1414
# see reference from https://docs.blender.org/api/current/bpy.types.UIList.html#advanced-uilist-example-filtering-and-reordering
1515
for o in objs:
16-
if o.BSEQ.init:
16+
if o.BSEQ.init and len(o.users_collection)>0 and len(o.users_scene)>0:
1717
flt_flags.append(self.bitflag_filter_item)
1818
else:
1919
flt_flags.append(0)

0 commit comments

Comments
 (0)