[Bf-extensions-cvs] [afe8fd7c] master: Collection Manager: Fix QCD slot toggling error. Task: T69577

Ryan Inch noreply at git.blender.org
Wed Sep 16 05:38:23 CEST 2020


Commit: afe8fd7ce5e6e9d107c042e7e463909e407dbcae
Author: Ryan Inch
Date:   Tue Sep 15 23:33:16 2020 -0400
Branches: master
https://developer.blender.org/rBAafe8fd7ce5e6e9d107c042e7e463909e407dbcae

Collection Manager: Fix QCD slot toggling error. Task: T69577

Fixes QCD slots being unable to be toggled on when they contain
objects in edit mode.
Fixes an error when toggling and there is no active object.

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

M	object_collection_manager/__init__.py
M	object_collection_manager/qcd_operators.py

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

diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py
index 769c60b5..72a279d1 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": (2, 14, 2),
+    "version": (2, 14, 3),
     "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/qcd_operators.py b/object_collection_manager/qcd_operators.py
index b64c87f8..6b5bce4a 100644
--- a/object_collection_manager/qcd_operators.py
+++ b/object_collection_manager/qcd_operators.py
@@ -222,10 +222,11 @@ class ViewQCDSlot(Operator):
 
         if self.toggle:
             # check if slot can be toggled off.
-            for obj in qcd_laycol.collection.objects:
-                if obj.mode != 'OBJECT':
-                    if obj.mode not in ['POSE', 'WEIGHT_PAINT'] or obj == locked_active_obj:
-                        return {'CANCELLED'}
+            if not qcd_laycol.exclude:
+                for obj in qcd_laycol.collection.objects:
+                    if obj.mode != 'OBJECT':
+                        if obj.mode not in ['POSE', 'WEIGHT_PAINT'] or obj == locked_active_obj:
+                            return {'CANCELLED'}
 
             # get current child exclusion state
             child_exclusion = []
@@ -242,15 +243,6 @@ class ViewQCDSlot(Operator):
             for laycol in child_exclusion:
                 laycol[0].exclude = laycol[1]
 
-            # restore locked objects back to their original mode
-            # needed because of exclude child updates
-            if locked_objs:
-                context.view_layer.objects.active = locked_active_obj
-                bpy.ops.object.mode_set(mode=locked_objs_mode)
-
-            # set layer as active layer collection
-            context.view_layer.active_layer_collection = qcd_laycol
-
         else:
             # exclude all collections
             for laycol in layer_collections.values():
@@ -274,14 +266,17 @@ class ViewQCDSlot(Operator):
 
             apply_to_children(qcd_laycol, exclude_all_children)
 
-            # restore locked objects back to their original mode
-            # needed because of exclude child updates
-            if locked_objs:
-                context.view_layer.objects.active = locked_active_obj
+
+        # restore locked objects back to their original mode
+        # needed because of exclude child updates
+        if locked_objs:
+            context.view_layer.objects.active = locked_active_obj
+
+            if context.view_layer.objects.active:
                 bpy.ops.object.mode_set(mode=locked_objs_mode)
 
-            # set layer as active layer collection
-            context.view_layer.active_layer_collection = qcd_laycol
+        # set layer as active layer collection
+        context.view_layer.active_layer_collection = qcd_laycol
 
 
         # update header UI



More information about the Bf-extensions-cvs mailing list