[Bf-extensions-cvs] [1bc96468] master: Fix T76226: Crash when using node wrangler in pinned window

David Friedli noreply at git.blender.org
Wed Apr 29 16:07:25 CEST 2020


Commit: 1bc96468a144750348ea6b134d4aaf457d7cc6cf
Author: David Friedli
Date:   Wed Apr 29 16:05:08 2020 +0200
Branches: master
https://developer.blender.org/rBA1bc96468a144750348ea6b134d4aaf457d7cc6cf

Fix T76226: Crash when using node wrangler in pinned window

Differential Revision: https://developer.blender.org/D7567

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

M	node_wrangler.py

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

diff --git a/node_wrangler.py b/node_wrangler.py
index 808962f1..e9ba5e74 100644
--- a/node_wrangler.py
+++ b/node_wrangler.py
@@ -1796,18 +1796,14 @@ class NWEmissionViewer(Operator, NWBase):
                         cls.search_sockets(groupout, sockets, index=socket_index)
 
     @classmethod
-    def scan_nodes(cls, tree, selection, sockets):
-        # get all selcted nodes and all viewer sockets in a material tree
+    def scan_nodes(cls, tree, sockets):
+        # get all viewer sockets in a material tree
         for node in tree.nodes:
-            if node.select:
-                selection.append(node)
-                node.select = False
-
             if hasattr(node, "node_tree"):
                 for socket in node.node_tree.outputs:
                     if is_viewer_socket(socket) and (socket not in sockets):
                         sockets.append(socket)
-                cls.scan_nodes(node.node_tree, selection, sockets)
+                cls.scan_nodes(node.node_tree, sockets)
 
     def link_leads_to_used_socket(self, link):
         #return True if link leads to a socket that is already used in this material
@@ -1868,13 +1864,12 @@ class NWEmissionViewer(Operator, NWBase):
                             valid = True
                             break
             if valid:
-                # get material_output node, store selection, deselect all
+                # get material_output node
                 materialout = None  # placeholder node
-                selection = []
                 delete_sockets = []
 
-                #scan through every single node in tree including nodes inside of groups
-                self.scan_nodes(base_node_tree, selection, delete_sockets)
+                #scan through all nodes in tree including nodes inside of groups to find viewer sockets
+                self.scan_nodes(base_node_tree, delete_sockets)
 
                 materialout = self.get_shader_output_node(base_node_tree)
                 if not materialout:
@@ -1975,23 +1970,14 @@ class NWEmissionViewer(Operator, NWBase):
                         tree.outputs.remove(socket)
 
                 # Delete nodes
-                for node in delete_nodes:
-                    space.node_tree = node[0]
-                    node[1].select = True
-                    bpy.ops.node.delete()
-
-                # Restore selection
-                path = space.path
-                path.start(base_node_tree)
-                if len(path_to_tree):
-                    for tree in path_to_tree:
-                        path.append(tree)
+                for tree, node in delete_nodes:
+                    tree.nodes.remove(node)
 
                 nodes.active = active
-                for node in nodes:
-                    if node in selection:
-                        node.select = True
+                active.select = True
+
                 force_update(context)
+
             return {'FINISHED'}
         else:
             return {'CANCELLED'}



More information about the Bf-extensions-cvs mailing list