(&self, child: &dyn Element)
| 528 | } |
| 529 | |
| 530 | fn add(&self, child: &dyn Element) { |
| 531 | let mut comp = self.as_ref().borrow_mut(); |
| 532 | |
| 533 | assert!( |
| 534 | !comp.destroyed, |
| 535 | "Widget was already destroyed but is being interacted with" |
| 536 | ); |
| 537 | |
| 538 | if let Some(parent) = child.parent() { |
| 539 | parent.remove(child.id()); |
| 540 | |
| 541 | if parent.id() != self.id() { |
| 542 | comp.children.push(child.id()); |
| 543 | child.set_parent(Some(self.id())); |
| 544 | if comp.onchildadd.is_some() { |
| 545 | let _ = comp.onchildadd.get().try_send(child.id()); |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | if let Some(widget) = comp.canvas.as_ref() { |
| 550 | widget.sync_depth(); |
| 551 | } |
| 552 | } |
| 553 | } |
| 554 | |
| 555 | /// The child must be sure that his parent reference is correct. |
| 556 | /// The child must remove the parent reference by himself: child.set_parent(None); |
nothing calls this directly
no test coverage detected