mirror of
https://github.com/RGBCube/serenity
synced 2025-05-26 01:55:08 +00:00
LibGUI: Add GUI::Window::try_add_menu()
This is a fallible variant of add_menu() that returns ErrorOr.
This commit is contained in:
parent
6b79745aa4
commit
bde9c2bc65
2 changed files with 11 additions and 4 deletions
|
@ -1188,16 +1188,22 @@ Gfx::Bitmap* Window::back_bitmap()
|
|||
return m_back_store ? &m_back_store->bitmap() : nullptr;
|
||||
}
|
||||
|
||||
Menu& Window::add_menu(String name)
|
||||
ErrorOr<NonnullRefPtr<Menu>> Window::try_add_menu(String name)
|
||||
{
|
||||
Menu& menu = m_menubar->add_menu({}, move(name));
|
||||
auto menu = TRY(m_menubar->try_add_menu({}, move(name)));
|
||||
if (m_window_id) {
|
||||
menu.realize_menu_if_needed();
|
||||
WindowServerConnection::the().async_add_menu(m_window_id, menu.menu_id());
|
||||
menu->realize_menu_if_needed();
|
||||
WindowServerConnection::the().async_add_menu(m_window_id, menu->menu_id());
|
||||
}
|
||||
return menu;
|
||||
}
|
||||
|
||||
Menu& Window::add_menu(String name)
|
||||
{
|
||||
auto menu = MUST(try_add_menu(move(name)));
|
||||
return *menu;
|
||||
}
|
||||
|
||||
bool Window::is_modified() const
|
||||
{
|
||||
if (!m_window_id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue