[Bf-extensions-cvs] [4e3539fa] master: Collection Manager: Fix selection bug. Task: T69577

Ryan Inch noreply at git.blender.org
Thu Jan 9 04:23:01 CET 2020


Commit: 4e3539fa890a0f4f43269751b28476122c8b9f6d
Author: Ryan Inch
Date:   Wed Jan 8 21:28:45 2020 -0500
Branches: master
https://developer.blender.org/rBA4e3539fa890a0f4f43269751b28476122c8b9f6d

Collection Manager: Fix selection bug. Task: T69577

Prevents the selection in the treeview from throwing an error
when there is only the master collection.

===================================================================

M	object_collection_manager/__init__.py
M	object_collection_manager/ui.py

===================================================================

diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py
index e5ca072f..4d19a5da 100644
--- a/object_collection_manager/__init__.py
+++ b/object_collection_manager/__init__.py
@@ -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
diff --git a/object_collection_manager/ui.py b/object_collection_manager/ui.py
index 2a37a197..604f105d 100644
--- a/object_collection_manager/ui.py
+++ b/object_collection_manager/ui.py
@@ -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



More information about the Bf-extensions-cvs mailing list