mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-24 06:49:24 -05:00
Check for widget != nullptr before add/remove child.
This commit is contained in:
parent
dab801e167
commit
dc30911e0f
@ -304,10 +304,12 @@ void View::paint(Painter& painter) {
|
||||
}
|
||||
|
||||
void View::add_child(Widget* const widget) {
|
||||
if( widget->parent() == nullptr ) {
|
||||
widget->set_parent(this);
|
||||
children_.push_back(widget);
|
||||
widget->set_dirty();
|
||||
if( widget ) {
|
||||
if( widget->parent() == nullptr ) {
|
||||
widget->set_parent(this);
|
||||
children_.push_back(widget);
|
||||
widget->set_dirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,11 +320,13 @@ void View::add_children(const std::vector<Widget*>& children) {
|
||||
}
|
||||
|
||||
void View::remove_child(Widget* const widget) {
|
||||
children_.erase(std::remove(children_.begin(), children_.end(), widget), children_.end());
|
||||
dirty_screen_rect += widget->screen_rect();
|
||||
widget->set_parent(nullptr);
|
||||
if( dirty_screen_rect ) {
|
||||
set_dirty();
|
||||
if( widget ) {
|
||||
children_.erase(std::remove(children_.begin(), children_.end(), widget), children_.end());
|
||||
dirty_screen_rect += widget->screen_rect();
|
||||
widget->set_parent(nullptr);
|
||||
if( dirty_screen_rect ) {
|
||||
set_dirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user