summaryrefslogtreecommitdiff
path: root/starling
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@vistahigherlearning.com>2019-07-15 07:45:47 -0400
committerDavid Thompson <dthompson@vistahigherlearning.com>2019-07-15 07:45:47 -0400
commita8a03957c563fc87272e51de3b69d11d57828aae (patch)
treeb52f6a18ef5cb3a6c78f5301b64e0143ea5ae59e /starling
parent4a9357d489352102570a6a2d7afb3bf096105195 (diff)
node: Noop when detaching a node without a parent.
In practice, throwing an error was real annoying.
Diffstat (limited to 'starling')
-rw-r--r--starling/node.scm17
1 files changed, 8 insertions, 9 deletions
diff --git a/starling/node.scm b/starling/node.scm
index 920a9bd..a0141c1 100644
--- a/starling/node.scm
+++ b/starling/node.scm
@@ -247,15 +247,14 @@ represented as a ratio in the range [0, 1]."
(define-method (detach (node <node>))
"Detach NODE from its parent."
(let ((p (parent node)))
- (unless p
- (error "node has no parent" node))
- (set! (children p) (delq node (children p)))
- (hashq-remove! (children-map p) (name node))
- ;; Detaching deactives the node and all of its children.
- (when (active? node)
- (deactivate node))
- (set! (parent node) #f)
- (on-detach p node)))
+ (when p
+ (set! (children p) (delq node (children p)))
+ (hashq-remove! (children-map p) (name node))
+ ;; Detaching deactives the node and all of its children.
+ (when (active? node)
+ (deactivate node))
+ (set! (parent node) #f)
+ (on-detach p node))))
(define-method (detach . nodes)
"Detach all NODES from their respective parents."