From 54e676b36fc06c07bfa9a922daaabcbe25ad6df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 4 Nov 2016 12:05:21 +0100 Subject: [PATCH] Only send 'unlink' cmd to Attract if ObjectID no longer used in edit. Previously it would always send 'unlink', even when a duplicate strip was removed. --- blender_cloud/attract/__init__.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/blender_cloud/attract/__init__.py b/blender_cloud/attract/__init__.py index a15ee6b..cdde083 100644 --- a/blender_cloud/attract/__init__.py +++ b/blender_cloud/attract/__init__.py @@ -440,14 +440,28 @@ class AttractStripUnlink(AttractOperatorMixin, Operator): bl_description = 'Remove Attract props from the selected strip(s)' def execute(self, context): + unlinked_ids = set() + + # First remove the Attract properties from the strips. for strip in context.selected_sequences: atc_object_id = getattr(strip, 'atc_object_id') remove_atc_props(strip) if atc_object_id: - node = Node({'_id': atc_object_id}) - pillar.sync_call(node.patch, {'op': 'unlink'}) - self.report({'INFO'}, 'Shot %s has been unlinked from Attract.' % atc_object_id) + unlinked_ids.add(atc_object_id) + + # For all Object IDs that are no longer in use in the edit, let Attract know. + # This should be done with care, as the shot could have been attached to multiple + # strips. + id_to_shots = compute_strip_conflicts(context) + for oid in unlinked_ids: + if len(id_to_shots[oid]): + # Still in use + continue + + node = Node({'_id': oid}) + pillar.sync_call(node.patch, {'op': 'unlink'}) + self.report({'INFO'}, 'Shot %s has been marked as Unused.' % oid) draw.tag_redraw_all_sequencer_editors() return {'FINISHED'}