1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:48:11 +00:00

WindowServer: Fix an assertion

Now that the window used by a WSMenu is its child CObject, the menu also
receives CChildEvent's about the window, including CEvent::ChildAdded when
the window gets created. At this point, menu_window() still returns nullptr,
so stop unconditionally assuming that it doesn't. We should not care whether
or not we have a window for unrelated events anyway.
This commit is contained in:
Sergey Bugaev 2019-08-19 14:32:18 +03:00 committed by Andreas Kling
parent 338ba238ca
commit d11d847161

View file

@ -157,8 +157,8 @@ void WSMenu::draw()
void WSMenu::event(CEvent& event)
{
ASSERT(menu_window());
if (event.type() == WSEvent::MouseMove) {
ASSERT(menu_window());
auto* item = item_at(static_cast<const WSMouseEvent&>(event).position());
if (!item || m_hovered_item == item)
return;
@ -168,6 +168,7 @@ void WSMenu::event(CEvent& event)
}
if (event.type() == WSEvent::MouseUp) {
ASSERT(menu_window());
if (!m_hovered_item)
return;
if (m_hovered_item->is_enabled())