From da254af886be85817ea902cdc8da369fa556dddd Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Tue, 14 Jul 2015 21:53:38 -0400 Subject: [PATCH] More improper linkage protection --- korman/nodes/node_conditions.py | 6 ++++++ korman/nodes/node_python.py | 16 +++++++++++++++- korman/nodes/node_responder.py | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/korman/nodes/node_conditions.py b/korman/nodes/node_conditions.py index ce2333c..a632e51 100644 --- a/korman/nodes/node_conditions.py +++ b/korman/nodes/node_conditions.py @@ -27,6 +27,9 @@ class PlasmaClickableNode(PlasmaNodeVariableInput, bpy.types.Node): bl_label = "Clickable" bl_width_default = 160 + # These are the Python attributes we can fill in + pl_attrib = {"ptAttribActivator", "ptAttribActivatorList", "ptAttribNamedActivator"} + clickable = StringProperty(name="Clickable", description="Mesh that is clickable") bounds = EnumProperty(name="Bounds", @@ -285,6 +288,9 @@ class PlasmaVolumeSensorNode(PlasmaNodeBase, bpy.types.Node): bl_label = "Region Sensor" bl_width_default = 190 + # These are the Python attributes we can fill in + pl_attrib = {"ptAttribActivator", "ptAttribActivatorList", "ptAttribNamedActivator"} + # Region Mesh region = StringProperty(name="Region", description="Object that defines the region mesh") diff --git a/korman/nodes/node_python.py b/korman/nodes/node_python.py index 9845b68..9ffd3d9 100644 --- a/korman/nodes/node_python.py +++ b/korman/nodes/node_python.py @@ -220,6 +220,20 @@ class PlasmaPythonFileNode(PlasmaNodeBase, bpy.types.Node): if self.no_update: return with self._NoUpdate(self) as _no_recurse: + # First, we really want to make sure our junk matches up. Yes, this does dupe what + # happens in PlasmaAttribNodeBase, but we can link much more than those node types... + toasty_sockets = [] + input_nodes = (i for i in self.inputs if i.is_linked and i.links) + for i in input_nodes: + link = i.links[0] + allowed_attribs = getattr(link.from_node, "pl_attrib", set()) + if i.attribute_type not in allowed_attribs: + self.id_data.links.remove(link) + # Bad news, old chap... Even though we're doing this before we figure out + # how many socket we need, the changes won't be committed to the socket's links + # until later. damn. We'll have to track it manually + toasty_sockets.append(i) + attribs = self.attribute_map empty = not self.inputs for idx in sorted(attribs): @@ -235,7 +249,7 @@ class PlasmaPythonFileNode(PlasmaNodeBase, bpy.types.Node): if not inputs: self._make_attrib_socket(attrib, empty) elif attrib.attribute_type not in _single_user_attribs: - unconnected = [socket for socket in inputs if not socket.is_linked] + unconnected = [socket for socket in inputs if not socket.is_linked or socket in toasty_sockets] if not unconnected: self._make_attrib_socket(attrib, empty) while len(unconnected) > 1: diff --git a/korman/nodes/node_responder.py b/korman/nodes/node_responder.py index 9ad6ab0..8fdcb33 100644 --- a/korman/nodes/node_responder.py +++ b/korman/nodes/node_responder.py @@ -26,6 +26,9 @@ class PlasmaResponderNode(PlasmaNodeVariableInput, bpy.types.Node): bl_label = "Responder" bl_width_default = 145 + # These are the Python attributes we can fill in + pl_attrib = {"ptAttribResponder", "ptAttribResponderList", "ptAttribNamedResponder"} + detect_trigger = BoolProperty(name="Detect Trigger", description="When notified, trigger the Responder", default=True)