Skip to content

Commit 1a6d3fc

Browse files
authored
Merge pull request #388 from jchanvfx/bug_fixes_tweaks
address issues from the last release.
2 parents bea91e9 + f13d0c8 commit 1a6d3fc

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

NodeGraphQt/base/graph.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,8 @@ def clear_session(self):
16601660
"""
16611661
Clears the current node graph session.
16621662
"""
1663-
for n in self.all_nodes():
1663+
nodes = self.all_nodes()
1664+
for n in nodes:
16641665
if isinstance(n, BaseNode):
16651666
for p in n.input_ports():
16661667
if p.locked():
@@ -1670,7 +1671,7 @@ def clear_session(self):
16701671
if p.locked():
16711672
p.set_locked(False, connected_ports=False)
16721673
p.clear_connections()
1673-
self._undo_stack.push(NodeRemovedCmd(self, n))
1674+
self._undo_stack.push(NodesRemovedCmd(self, nodes))
16741675
self._undo_stack.clear()
16751676
self._model.session = ''
16761677

@@ -1819,9 +1820,12 @@ def _deserialize(self, data, relative_pos=False, pos=None):
18191820
allow_connection = any([not in_port.model.connected_ports,
18201821
in_port.model.multi_connection])
18211822
if allow_connection:
1822-
self._undo_stack.push(PortConnectedCmd(in_port, out_port))
1823+
self._undo_stack.push(
1824+
PortConnectedCmd(in_port, out_port, emit_signal=False)
1825+
)
18231826

1824-
# Run on_input_connected to ensure connections are fully set up after deserialization.
1827+
# Run on_input_connected to ensure connections are fully set up
1828+
# after deserialization.
18251829
in_node.on_input_connected(in_port, out_port)
18261830

18271831
node_objs = nodes.values()
@@ -2009,8 +2013,7 @@ def cut_nodes(self, nodes=None):
20092013
if isinstance(node, GroupNode) and node.is_expanded:
20102014
node.collapse()
20112015

2012-
self._undo_stack.push(NodeRemovedCmd(self, node))
2013-
2016+
self._undo_stack.push(NodesRemovedCmd(self, nodes))
20142017
self._undo_stack.endMacro()
20152018

20162019
def paste_nodes(self):
@@ -2681,7 +2684,9 @@ def _deserialize(self, data, relative_pos=False, pos=None):
26812684
out_port = out_node.outputs().get(pname) if out_node else None
26822685

26832686
if in_port and out_port:
2684-
self._undo_stack.push(PortConnectedCmd(in_port, out_port))
2687+
self._undo_stack.push(
2688+
PortConnectedCmd(in_port, out_port, emit_signal=False)
2689+
)
26852690

26862691
node_objs = list(nodes.values())
26872692
if relative_pos:

NodeGraphQt/nodes/base_node.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,13 @@ def add_checkbox(self, name, label='', text='', state=False, tooltip=None,
301301
#: redraw node to address calls outside the "__init__" func.
302302
self.view.draw_node()
303303

304-
def hide_widget(self, name):
304+
def hide_widget(self, name, push_undo=True):
305305
"""
306306
Hide an embedded node widget.
307307
308308
Args:
309309
name (str): node property name for the widget.
310+
push_undo (bool): register the command to the undo stack. (default: True)
310311
311312
See Also:
312313
:meth:`BaseNode.add_custom_widget`,
@@ -316,14 +317,18 @@ def hide_widget(self, name):
316317
if not self.view.has_widget(name):
317318
return
318319
undo_cmd = NodeWidgetVisibleCmd(self, name, visible=False)
319-
self.graph.undo_stack().push(undo_cmd)
320+
if push_undo:
321+
self.graph.undo_stack().push(undo_cmd)
322+
else:
323+
undo_cmd.redo()
320324

321-
def show_widget(self, name):
325+
def show_widget(self, name, push_undo=True):
322326
"""
323327
Show an embedded node widget.
324328
325329
Args:
326330
name (str): node property name for the widget.
331+
push_undo (bool): register the command to the undo stack. (default: True)
327332
328333
See Also:
329334
:meth:`BaseNode.add_custom_widget`,
@@ -333,7 +338,10 @@ def show_widget(self, name):
333338
if not self.view.has_widget(name):
334339
return
335340
undo_cmd = NodeWidgetVisibleCmd(self, name, visible=True)
336-
self.graph.undo_stack().push(undo_cmd)
341+
if push_undo:
342+
self.graph.undo_stack().push(undo_cmd)
343+
else:
344+
undo_cmd.redo()
337345

338346
def add_input(self, name='input', multi_input=False, display_name=True,
339347
color=None, locked=False, painter_func=None):

NodeGraphQt/nodes/group_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def add_output(self, name='output', multi_output=True, display_name=True,
149149

150150
def delete_input(self, port):
151151
if type(port) in [int, str]:
152-
port = self.get_output(port)
152+
port = self.get_input(port)
153153
if port is None:
154154
return
155155

0 commit comments

Comments
 (0)