From 06328e8aeaddf7c6df1a758ed9cbb3c535d651f5 Mon Sep 17 00:00:00 2001
From: Ryan Inch <mythologylover75@gmail.com>
Date: Thu, 22 Jun 2023 02:12:12 -0400
Subject: [PATCH] Collection Manager: Fix error restoring disabled objects.
 Task: #69577

Restoring disabled objects would attempt to restore objects
in disabled collections, causing an error when attempting to
select them, this limits it to just restoring objects in the
current view layer.

Fixes #102661
---
 object_collection_manager/__init__.py  | 2 +-
 object_collection_manager/operators.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/object_collection_manager/__init__.py b/object_collection_manager/__init__.py
index ee3236b2f..c92a7b6ad 100644
--- a/object_collection_manager/__init__.py
+++ b/object_collection_manager/__init__.py
@@ -6,7 +6,7 @@ bl_info = {
     "name": "Collection Manager",
     "description": "Manage collections and their objects",
     "author": "Ryan Inch",
-    "version": (2, 24, 7),
+    "version": (2, 24, 8),
     "blender": (3, 0, 0),
     "location": "View3D - Object Mode (Shortcut - M)",
     "warning": '',  # used for warning icon and text in addons panel
diff --git a/object_collection_manager/operators.py b/object_collection_manager/operators.py
index 0b2b9cbfd..e4c6a96c0 100644
--- a/object_collection_manager/operators.py
+++ b/object_collection_manager/operators.py
@@ -1509,7 +1509,7 @@ class CMRestoreDisabledObjectsOperator(Operator):
 
     def execute(self, context):
         for obj in bpy.data.objects:
-            if obj.hide_viewport:
+            if obj.name in context.view_layer.objects and obj.hide_viewport:
                 obj.hide_viewport = False
                 obj.select_set(True)
 
-- 
GitLab