Skip to content
Snippets Groups Projects
Commit afe8fd7c authored by Ryan Inch's avatar Ryan Inch
Browse files

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.
parent 32f0fe86
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment