Skip to content

Commit 1f7cd06

Browse files
committed
handle errors during start
1 parent b1a6709 commit 1f7cd06

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

src/handler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ def handle_error(error, location, **kwargs):
3030

3131
def cleanup(location, objects=frozenset()):
3232
if location == "START":
33-
# everything created since the operator started is scrap
33+
# the delete below would take a live session's objects too
34+
if manager.is_active:
35+
return
36+
# every object created since the operator started is temporary
3437
for obj in set(bpy.data.objects).difference(objects):
3538
bpy.data.objects.remove(obj, do_unlink=True)
3639

src/ops/start.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,10 @@ def tick(self):
174174
return None
175175

176176
except Exception as e:
177-
# handle_error removes objects created since start, incl the temp
178-
# pieces, so only the collection data-block is left to remove
179177
handle_error(e, "START", objects=self.start_objects)
178+
# handle_error leaves these alone during a live session
179+
for piece in list(self.temp_collection.objects):
180+
bpy.data.objects.remove(piece, do_unlink=True)
180181
bpy.data.collections.remove(self.temp_collection)
181182
manager.hold_count -= 1
182183
# settle the pieces that never got exported so their groups and
@@ -463,6 +464,9 @@ def tick(self):
463464
# an undo past the session start kills the collection datablock,
464465
# and a second ReferenceError here would wedge the hold count
465466
if check_exists(self.temp_collection):
467+
# handle_error leaves these alone during a live session
468+
for piece in list(self.temp_collection.objects):
469+
bpy.data.objects.remove(piece, do_unlink=True)
466470
bpy.data.collections.remove(self.temp_collection)
467471
manager.hold_count -= 1
468472
for name in self.preparing:

0 commit comments

Comments
 (0)