Skip to content

Commit 31bc82c

Browse files
committed
added port checks to prevent infinite loops
1 parent 02f8906 commit 31bc82c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

NodeGraphQt/base/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ def set_property(self, name, value, push_undo=True):
393393
push_undo (bool): register the command to the undo stack. (default: True)
394394
"""
395395

396-
# prevent signals from causing a infinite loop.
396+
# prevent signals from causing an infinite loop.
397397
if self.get_property(name) == value:
398398
return
399399

NodeGraphQt/base/port.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ def set_visible(self, visible=True, push_undo=True):
117117
visible (bool): true if visible.
118118
push_undo (bool): register the command to the undo stack. (default: True)
119119
"""
120+
121+
# prevent signals from causing an infinite loop.
122+
if visible == self.visible():
123+
return
124+
120125
undo_cmd = PortVisibleCmd(self, visible)
121126
if push_undo:
122127
undo_stack = self.node().graph.undo_stack()
@@ -165,8 +170,12 @@ def set_locked(self, state=False, connected_ports=True, push_undo=True):
165170
state (Bool): port lock state.
166171
connected_ports (Bool): apply to lock state to connected ports.
167172
push_undo (bool): register the command to the undo stack. (default: True)
168-
169173
"""
174+
175+
# prevent signals from causing an infinite loop.
176+
if state == self.locked():
177+
return
178+
170179
graph = self.node().graph
171180
undo_stack = graph.undo_stack()
172181
if state:
@@ -440,7 +449,7 @@ def add_reject_port_type(self, port_name, port_type, node_type):
440449
node_type (str): port node type.
441450
"""
442451
# storing the connection constrain at the graph level instead of the
443-
# port level so we don't serialize the same data for every port
452+
# port level, so we don't serialize the same data for every port
444453
# instance.
445454
self.node().add_reject_port_type(
446455
port=self,

0 commit comments

Comments
 (0)