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