The child must be sure that his parent reference is correct. The child must remove the parent reference by himself: child.set_parent(None);
(&self, child: Id)
| 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); |
| 557 | fn remove(&self, child: Id) { |
| 558 | let mut comp = self.as_ref().borrow_mut(); |
| 559 | |
| 560 | assert!( |
| 561 | !comp.destroyed, |
| 562 | "Widget was already destroyed but is being interacted with" |
| 563 | ); |
| 564 | |
| 565 | if let Some(index) = comp.children.iter().position(|x| x == &child) { |
| 566 | comp.children.remove(index); |
| 567 | |
| 568 | if comp.onchildremove.is_some() { |
| 569 | let _ = comp.onchildremove.get().try_send(child); |
| 570 | } |
| 571 | |
| 572 | if let Some(widget) = comp.canvas.as_ref() { |
| 573 | widget.sync_depth(); |
| 574 | } |
| 575 | } |
| 576 | } |
| 577 | |
| 578 | fn children_bounds(&self) -> ChildBounds { |
| 579 | let mut comp = self.as_ref().borrow_mut(); |
no test coverage detected