|
12 | 12 | from NodeGraphQt.base.factory import NodeFactory |
13 | 13 | from NodeGraphQt.base.menu import NodeGraphMenu, NodesMenu |
14 | 14 | from NodeGraphQt.base.model import NodeGraphModel |
15 | | -from NodeGraphQt.base.node import NodeObject |
| 15 | +from NodeGraphQt.base.node import NodeObject,BaseNode |
16 | 16 | from NodeGraphQt.base.port import Port |
17 | 17 | from NodeGraphQt.constants import (DRAG_DROP_ID, |
18 | 18 | PIPE_LAYOUT_CURVED, |
@@ -121,17 +121,21 @@ def _wire_signals(self): |
121 | 121 | self._viewer.node_selected.connect(self._on_node_selected) |
122 | 122 | self._viewer.data_dropped.connect(self._on_node_data_dropped) |
123 | 123 |
|
124 | | - def _insert_node(self,items): |
| 124 | + def _insert_node(self, items): |
125 | 125 | pipe = items[0] |
126 | 126 | node = self.get_node_by_id(items[1]) |
| 127 | + if not isinstance(node,BaseNode): |
| 128 | + return |
127 | 129 |
|
128 | 130 | disconnected = [(pipe.input_port, pipe.output_port)] |
129 | 131 | connected = [] |
| 132 | + |
130 | 133 | if node.inputs(): |
131 | | - connected.append((pipe.output_port,node.input(0).view)) |
| 134 | + connected.append((pipe.output_port, list(node.inputs().values())[0].view)) |
132 | 135 | if node.outputs(): |
133 | | - connected.append((node.output(0).view,pipe.input_port)) |
134 | | - self._on_connection_changed(disconnected,connected) |
| 136 | + connected.append((list(node.outputs().values())[0].view, pipe.input_port)) |
| 137 | + |
| 138 | + self._on_connection_changed(disconnected, connected) |
135 | 139 |
|
136 | 140 | def _toggle_tab_search(self): |
137 | 141 | """ |
@@ -885,7 +889,6 @@ def _serialize(self, nodes): |
885 | 889 | serial_data = {'nodes': {}, 'connections': []} |
886 | 890 | nodes_data = {} |
887 | 891 | for n in nodes: |
888 | | - |
889 | 892 | # update the node model. |
890 | 893 | n.update_model() |
891 | 894 |
|
|
0 commit comments