aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/Components')
-rw-r--r--lib/python/Components/Element.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/python/Components/Element.py b/lib/python/Components/Element.py
index 6f812b20..fc709139 100644
--- a/lib/python/Components/Element.py
+++ b/lib/python/Components/Element.py
@@ -25,6 +25,24 @@ class Element:
self.connectUpstream(upstream)
upstream.connectDownstream(self)
+ # we disconnect from down to up
+ def disconnectAll(self):
+ # we should not disconnect from upstream if
+ # there are still elements depending on us.
+ assert len(self.downstream_elements) == 0, "there are still downstream elements left"
+
+ # disconnect all upstream elements from us
+ for upstream in self.upstream_elements:
+ upstream.disconnectDownstream(self)
+
+ def disconnectDownstream(self, downstream):
+ self.downstream_elements.remove(downstream)
+ if self.master == downstream:
+ self.master = None
+
+ if len(self.downstream_elements) == 0:
+ self.disconnectAll()
+
# default action: push downstream
def changed(self):
self.downstream_elements.changed()