diff options
author | Ryan Inch <mythologylover75@gmail.com> | 2020-04-15 08:03:40 +0300 |
---|---|---|
committer | Ryan Inch <mythologylover75@gmail.com> | 2020-04-15 08:03:40 +0300 |
commit | 88c3fc87b2bb1b6bac51672ef16840478e273e5d (patch) | |
tree | 8441d051f8865acfe19c7f8218c80d8fefdd71c0 /object_collection_manager/internals.py | |
parent | 3c181d7e5c0dc4058fe971848407227b4fcf582e (diff) |
Collection Manager: Fix bug in name update. Task: T69577
Fix rto_history not getting updated on collection name change.
Diffstat (limited to 'object_collection_manager/internals.py')
-rw-r--r-- | object_collection_manager/internals.py | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/object_collection_manager/internals.py b/object_collection_manager/internals.py index 05432ab6..0b5b4333 100644 --- a/object_collection_manager/internals.py +++ b/object_collection_manager/internals.py @@ -227,6 +227,7 @@ qcd_slots = QCDSlots() def update_col_name(self, context): global layer_collections global qcd_slots + global rto_history if self.name != self.last_name: if self.name == '': @@ -235,6 +236,8 @@ def update_col_name(self, context): # if statement prevents update on list creation if self.last_name != '': + view_layer_name = context.view_layer.name + # update collection name layer_collections[self.last_name]["ptr"].collection.name = self.name @@ -253,10 +256,30 @@ def update_col_name(self, context): qcd_slots.overrides.remove(self.last_name) qcd_slots.overrides.add(self.name) + # update history + rtos = [ + "exclude", + "select", + "hide", + "disable", + "render" + ] + + orig_targets = { + rto: rto_history[rto][view_layer_name]["target"] + for rto in rtos + if rto_history[rto].get(view_layer_name) + } + + for rto in rtos: + history = rto_history[rto].get(view_layer_name) + + if history and orig_targets[rto] == self.last_name: + history["target"] = self.name + + # update names in expanded, qcd slots, and rto_history for any other + # collection names that changed as a result of this name change cm_list_collection = context.scene.collection_manager.cm_list_collection - - # update names in expanded and qcd slots for any other collection names - # that changed as a result of this name change count = 0 laycol_iter_list = list(context.view_layer.layer_collection.children) @@ -284,6 +307,13 @@ def update_col_name(self, context): qcd_slots.overrides.add(layer_collection.name) + # update history + for rto in rtos: + history = rto_history[rto].get(view_layer_name) + + if history and orig_targets[rto] == cm_list_item.last_name: + history["target"] = layer_collection.name + if layer_collection.children: laycol_iter_list[0:0] = list(layer_collection.children) |