Collection Manager: Fix selection bug. Task: T69577

Prevents the selection in the treeview from throwing an error
when there is only the master collection.
This commit is contained in:
Ryan Inch 2020-01-08 21:28:45 -05:00
parent bad59573c3
commit 4e3539fa89
2 changed files with 8 additions and 3 deletions

View File

@ -22,7 +22,7 @@ bl_info = {
"name": "Collection Manager",
"description": "Manage collections and their objects",
"author": "Ryan Inch",
"version": (1,8,6),
"version": (1,8,7),
"blender": (2, 80, 0),
"location": "View3D - Object Mode (Shortcut - M)",
"warning": '', # used for warning icon and text in addons panel

View File

@ -177,7 +177,7 @@ class CollectionManager(Operator):
active_laycol_row_index = layer_collections[active_laycol_name]["row_index"]
context.scene.CMListIndex = active_laycol_row_index
except:
context.scene.CMListIndex = 0
context.scene.CMListIndex = -1
if context.scene.CM_Phantom_Mode:
if set(layer_collections.keys()) != set(phantom_history["initial_state"].keys()):
@ -190,7 +190,12 @@ class CollectionManager(Operator):
def update_selection(self, context):
selected_item = context.scene.CMListCollection[context.scene.CMListIndex]
scn = context.scene
if scn.CMListIndex == -1:
return
selected_item = scn.CMListCollection[scn.CMListIndex]
layer_collection = layer_collections[selected_item.name]["ptr"]
context.view_layer.active_layer_collection = layer_collection