Fix adding certain nodes can cause python errors

Adding nodes via `NodeAddOperator` could fail if the node's poll fails
in `rna_NodeTree_node_new`. Examples are trying to add a RenderLayers
node or a Cryptomatte node to a nodegroup.

Now except the python error and use blender error reporting only instead
of throwing full python stacktraces at the user.

Differential Revision: https://developer.blender.org/D14584
This commit is contained in:
Philipp Oeser 2022-04-07 10:31:52 +02:00
parent e7a69b438f
commit 4aac251b42
1 changed files with 5 additions and 1 deletions

View File

@ -73,7 +73,11 @@ class NodeAddOperator:
for n in tree.nodes:
n.select = False
node = tree.nodes.new(type=node_type)
try:
node = tree.nodes.new(type=node_type)
except RuntimeError as e:
self.report({'ERROR'}, str(e))
return None
for setting in self.settings:
# XXX catch exceptions here?