glTF exporter: fix crash with weird missing datablock node group

This commit is contained in:
Julien Duroure 2022-11-28 15:20:48 +01:00 committed by Philipp Oeser
parent 1c1b05efd3
commit 6f4089e1f5
Notes: blender-bot 2023-02-13 13:22:21 +01:00
Referenced by issue blender/blender#100749: Blender LTS: Maintenance Task 3.3
Referenced by issue blender/blender#100749, Blender LTS: Maintenance Task 3.3
2 changed files with 3 additions and 1 deletions

View File

@ -4,7 +4,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
"version": (3, 3, 35),
"version": (3, 3, 36),
'blender': (3, 3, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',

View File

@ -96,8 +96,10 @@ def get_socket_old(blender_material: bpy.types.Material, name: str):
"""
gltf_node_group_names = [get_gltf_node_name().lower(), get_gltf_node_old_name().lower()]
if blender_material.node_tree and blender_material.use_nodes:
# Some weird node groups with missing datablock can have no node_tree, so checking n.node_tree (See #1797)
nodes = [n for n in blender_material.node_tree.nodes if \
isinstance(n, bpy.types.ShaderNodeGroup) and \
n.node_tree is not None and
(n.node_tree.name.startswith('glTF Metallic Roughness') or n.node_tree.name.lower() in gltf_node_group_names)]
inputs = sum([[input for input in node.inputs if input.name == name] for node in nodes], [])
if inputs: