Skip to content

Commit

Permalink
added port checks to prevent infinite loops
Browse files Browse the repository at this point in the history
  • Loading branch information
jchanvfx committed Jul 15, 2023
1 parent 02f8906 commit 31bc82c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion NodeGraphQt/base/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def set_property(self, name, value, push_undo=True):
push_undo (bool): register the command to the undo stack. (default: True)
"""

# prevent signals from causing a infinite loop.
# prevent signals from causing an infinite loop.
if self.get_property(name) == value:
return

Expand Down
13 changes: 11 additions & 2 deletions NodeGraphQt/base/port.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ def set_visible(self, visible=True, push_undo=True):
visible (bool): true if visible.
push_undo (bool): register the command to the undo stack. (default: True)
"""

# prevent signals from causing an infinite loop.
if visible == self.visible():
return

undo_cmd = PortVisibleCmd(self, visible)
if push_undo:
undo_stack = self.node().graph.undo_stack()
Expand Down Expand Up @@ -165,8 +170,12 @@ def set_locked(self, state=False, connected_ports=True, push_undo=True):
state (Bool): port lock state.
connected_ports (Bool): apply to lock state to connected ports.
push_undo (bool): register the command to the undo stack. (default: True)
"""

# prevent signals from causing an infinite loop.
if state == self.locked():
return

graph = self.node().graph
undo_stack = graph.undo_stack()
if state:
Expand Down Expand Up @@ -440,7 +449,7 @@ def add_reject_port_type(self, port_name, port_type, node_type):
node_type (str): port node type.
"""
# storing the connection constrain at the graph level instead of the
# port level so we don't serialize the same data for every port
# port level, so we don't serialize the same data for every port
# instance.
self.node().add_reject_port_type(
port=self,
Expand Down

0 comments on commit 31bc82c

Please sign in to comment.