From a3e5af042fa49d1d03169d36ed75e14a6933d07b Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Wed, 23 Sep 2020 23:00:04 -0400 Subject: [PATCH] Fix #205. --- korman/nodes/node_responder.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/korman/nodes/node_responder.py b/korman/nodes/node_responder.py index a400182..10ccf69 100644 --- a/korman/nodes/node_responder.py +++ b/korman/nodes/node_responder.py @@ -291,7 +291,7 @@ class PlasmaResponderStateNode(PlasmaNodeBase, bpy.types.Node): # Convert the commands commands = CommandMgr(stateMgr.responder) - for i in self.find_outputs("msgs"): + for i in self._get_child_messages(): # slight optimization--commands attached to states can't wait on other commands # namely because it's impossible to wait on a command that doesn't exist... self._generate_command(exporter, so, stateMgr.responder, commands, i) @@ -340,16 +340,24 @@ class PlasmaResponderStateNode(PlasmaNodeBase, bpy.types.Node): if msgNode.has_callbacks: commandMgr.add_waitable_node(msgNode) - if msgNode.find_output("msgs"): + if msgNode.has_linked_callbacks: childWaitOn = commandMgr.add_wait(idx) msgNode.convert_callback_message(exporter, so, msg, responder.key, childWaitOn) else: childWaitOn = waitOn # Export any linked callback messages - for i in msgNode.find_outputs("msgs"): + for i in self._get_child_messages(msgNode): self._generate_command(exporter, so, responder, commandMgr, i, childWaitOn) + def _get_child_messages(self, node=None): + """Returns a list of the message nodes sent by `node`. The list is sorted such that any + messages with callbacks are last in the list, allowing proper wait generation. + """ + if node is None: + node = self + return sorted(node.find_outputs("msgs"), key=lambda x: x.has_callbacks and x.has_linked_callbacks) + class PlasmaRespStateSocket(PlasmaNodeSocketBase, bpy.types.NodeSocket): bl_color = (0.388, 0.78, 0.388, 1.0)