From a8a03957c563fc87272e51de3b69d11d57828aae Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 15 Jul 2019 07:45:47 -0400 Subject: node: Noop when detaching a node without a parent. In practice, throwing an error was real annoying. --- starling/node.scm | 17 ++++++++--------- 1 file 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 )) "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." -- cgit v1.2.3