[Bf-blender-cvs] [4aac251b421] master: Fix adding certain nodes can cause python errors

Philipp Oeser noreply at git.blender.org
Mon Apr 11 18:50:38 CEST 2022


Commit: 4aac251b421b4576b06635d969f802db1d9a3d84
Author: Philipp Oeser
Date:   Thu Apr 7 10:31:52 2022 +0200
Branches: master
https://developer.blender.org/rB4aac251b421b4576b06635d969f802db1d9a3d84

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

===================================================================

M	release/scripts/startup/bl_operators/node.py

===================================================================

diff --git a/release/scripts/startup/bl_operators/node.py b/release/scripts/startup/bl_operators/node.py
index b8368cd1970..60a684ae5e8 100644
--- a/release/scripts/startup/bl_operators/node.py
+++ b/release/scripts/startup/bl_operators/node.py
@@ -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?



More information about the Bf-blender-cvs mailing list