mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 14:55:06 +00:00
LibGUI: Always invalidate layout on GWidget child removal.
This code can get a bit confused when the child is destroyed before we handle the ChildRemoved event. In those cases, the GChildEvent::child() getter will return nullptr as it's backed by a WeakPtr. To work around this issue, just always invalidate the layout for now. This can be made a lot tighter in the future.
This commit is contained in:
parent
d89d759c36
commit
e74f32ae40
1 changed files with 6 additions and 2 deletions
|
@ -28,8 +28,12 @@ void GWidget::child_event(GChildEvent& event)
|
|||
layout()->add_widget(static_cast<GWidget&>(*event.child()));
|
||||
}
|
||||
if (event.type() == GEvent::ChildRemoved) {
|
||||
if (event.child() && event.child()->is_widget() && layout())
|
||||
layout()->remove_widget(static_cast<GWidget&>(*event.child()));
|
||||
if (layout()) {
|
||||
if (event.child() && event.child()->is_widget())
|
||||
layout()->remove_widget(static_cast<GWidget&>(*event.child()));
|
||||
else
|
||||
invalidate_layout();
|
||||
}
|
||||
}
|
||||
return GObject::child_event(event);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue