mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00:00
LibGUI: Don't crash when updating menu item that's not in the window server (#83)
Don't crash when updating menu item that's not in the window server. Menu Items begin with an invalid ID of -1, and only get a valid ID if the menu they are attached to is added to the window server. They don't send updates to the server unless they have a valid ID. Fixes #82
This commit is contained in:
parent
ebf645d72a
commit
9823354754
4 changed files with 7 additions and 2 deletions
|
@ -32,6 +32,7 @@ GMenu::~GMenu()
|
|||
void GMenu::add_action(Retained<GAction> action)
|
||||
{
|
||||
m_items.append(make<GMenuItem>(m_menu_id, move(action)));
|
||||
dbgprintf("MenuItem Menu ID: %d\n", m_menu_id);
|
||||
}
|
||||
|
||||
void GMenu::add_separator()
|
||||
|
@ -70,6 +71,7 @@ int GMenu::realize_menu()
|
|||
auto response = GEventLoop::current().sync_request(request, WSAPI_ServerMessage::Type::DidCreateMenu);
|
||||
m_menu_id = response.menu.menu_id;
|
||||
|
||||
dbgprintf("GMenu: Realizing menu! New menu ID: %d", m_menu_id);
|
||||
ASSERT(m_menu_id > 0);
|
||||
for (int i = 0; i < m_items.size(); ++i) {
|
||||
auto& item = *m_items[i];
|
||||
|
@ -79,6 +81,7 @@ int GMenu::realize_menu()
|
|||
WSAPI_ClientMessage request;
|
||||
request.type = WSAPI_ClientMessage::Type::AddMenuSeparator;
|
||||
request.menu.menu_id = m_menu_id;
|
||||
dbgprintf("MenuItem [New] Menu ID: %d\n", m_menu_id);
|
||||
GEventLoop::current().sync_request(request, WSAPI_ServerMessage::Type::DidAddMenuSeparator);
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue