Amaranth: Fix Debug feature to list users of image datablocks

The code was looking for background images in the 3D Viewport, which have
been moved to Camera objects in 2.8.

Fixes T98252
This commit is contained in:
Pablo Vazquez 2022-07-24 04:26:46 +02:00
parent b364669bd7
commit 4a522d353a
Notes: blender-bot 2023-02-14 18:20:30 +01:00
Referenced by issue #98252, Amaranth toolset: list users for datablock razes error on finding images
2 changed files with 18 additions and 16 deletions

View File

@ -74,7 +74,7 @@ from amaranth.misc import (
bl_info = {
"name": "Amaranth Toolset",
"author": "Pablo Vazquez, Bassam Kurdali, Sergey Sharybin, Lukas Tönne, Cesar Saez, CansecoGPC",
"version": (1, 0, 10),
"version": (1, 0, 11),
"blender": (3, 2, 0),
"location": "Everywhere!",
"description": "A collection of tools and settings to improve productivity",

View File

@ -65,7 +65,7 @@ class AMTH_store_data():
'TEXTURE': [], # Textures (Psys, Brushes)
'MODIFIER': [], # Modifiers
'MESH_DATA': [], # Vertex Colors
'VIEW3D': [], # Background Images
'OUTLINER_OB_CAMERA': [], # Background Images
'NODETREE': [], # Compositor
}
libraries = [] # Libraries x type
@ -632,6 +632,7 @@ class AMTH_SCENE_OT_list_users_for_x(Operator):
if name not in AMTH_store_data.users['MATERIAL']:
AMTH_store_data.users['MATERIAL'].append(name)
# Check Lights
for la in d.lights:
# Cycles
@ -643,6 +644,7 @@ class AMTH_SCENE_OT_list_users_for_x(Operator):
no.image and no.image.name == x:
if la.name not in AMTH_store_data.users['LIGHT']:
AMTH_store_data.users['LIGHT'].append(la.name)
# Check World
for wo in d.worlds:
# Cycles
@ -654,6 +656,7 @@ class AMTH_SCENE_OT_list_users_for_x(Operator):
no.image and no.image.name == x:
if wo.name not in AMTH_store_data.users['WORLD']:
AMTH_store_data.users['WORLD'].append(wo.name)
# Check Textures
for te in d.textures:
if te and te.type == 'IMAGE' and te.image:
@ -662,6 +665,7 @@ class AMTH_SCENE_OT_list_users_for_x(Operator):
if name == x and \
name not in AMTH_store_data.users['TEXTURE']:
AMTH_store_data.users['TEXTURE'].append(te.name)
# Check Modifiers in Objects
for ob in d.objects:
for mo in ob.modifiers:
@ -672,21 +676,19 @@ class AMTH_SCENE_OT_list_users_for_x(Operator):
name = '"{0}" modifier in {1}'.format(mo.name, ob.name)
if name not in AMTH_store_data.users['MODIFIER']:
AMTH_store_data.users['MODIFIER'].append(name)
# Check Background Images in Viewports
for scr in d.screens:
for ar in scr.areas:
if ar.type == 'VIEW_3D':
if ar.spaces and \
ar.spaces.active and \
ar.spaces.active.background_images:
for bg in ar.spaces.active.background_images:
image = bg.image
if bg and image and image.name == x:
name = 'Background for 3D Viewport in Screen "{0}"'\
.format(scr.name)
if name not in AMTH_store_data.users['VIEW3D']:
AMTH_store_data.users['VIEW3D'].append(name)
# Check Background Images in Cameras
for ob in d.objects:
if ob and ob.type == 'CAMERA' and ob.data.background_images:
for bg in ob.data.background_images:
image = bg.image
if bg and image and image.name == x:
name = 'Used as background for Camera "{0}"'\
.format(ob.name)
if name not in AMTH_store_data.users['OUTLINER_OB_CAMERA']:
AMTH_store_data.users['OUTLINER_OB_CAMERA'].append(name)
# Check the Compositor
for sce in d.scenes:
if sce.node_tree and sce.node_tree.nodes: