summaryrefslogtreecommitdiff
path: root/Userland/DevTools
diff options
context:
space:
mode:
authorKarol Kosek <krkk@serenityos.org>2023-04-16 14:46:48 +0200
committerSam Atkins <atkinssj@gmail.com>2023-04-20 17:02:23 +0100
commit83af64f0531a9b388be227e86ae262a75f772fd0 (patch)
tree29996db3e66223e0781ef593c9705f2968f8dfb2 /Userland/DevTools
parent0b110c88ae27dcb1da16e577c8d6b9dbc8158369 (diff)
downloadserenity-83af64f0531a9b388be227e86ae262a75f772fd0.zip
SQLStudio: Propagate errors from `MainWidget::initialize_menubar()`
Diffstat (limited to 'Userland/DevTools')
-rw-r--r--Userland/DevTools/SQLStudio/MainWidget.cpp53
-rw-r--r--Userland/DevTools/SQLStudio/MainWidget.h2
-rw-r--r--Userland/DevTools/SQLStudio/main.cpp2
3 files changed, 29 insertions, 28 deletions
diff --git a/Userland/DevTools/SQLStudio/MainWidget.cpp b/Userland/DevTools/SQLStudio/MainWidget.cpp
index e51aa26f30..cc4abf2456 100644
--- a/Userland/DevTools/SQLStudio/MainWidget.cpp
+++ b/Userland/DevTools/SQLStudio/MainWidget.cpp
@@ -291,35 +291,36 @@ MainWidget::MainWidget()
};
}
-void MainWidget::initialize_menu(GUI::Window* window)
+ErrorOr<void> MainWidget::initialize_menu(GUI::Window* window)
{
- auto& file_menu = window->add_menu("&File"_short_string);
- file_menu.add_action(*m_new_action);
- file_menu.add_action(*m_open_action);
- file_menu.add_action(*m_save_action);
- file_menu.add_action(*m_save_as_action);
- file_menu.add_action(*m_save_all_action);
- file_menu.add_separator();
- file_menu.add_action(GUI::CommonActions::make_quit_action([](auto&) {
+ auto file_menu = TRY(window->try_add_menu("&File"_short_string));
+ TRY(file_menu->try_add_action(*m_new_action));
+ TRY(file_menu->try_add_action(*m_open_action));
+ TRY(file_menu->try_add_action(*m_save_action));
+ TRY(file_menu->try_add_action(*m_save_as_action));
+ TRY(file_menu->try_add_action(*m_save_all_action));
+ TRY(file_menu->try_add_separator());
+ TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([](auto&) {
GUI::Application::the()->quit();
- }));
-
- auto& edit_menu = window->add_menu("&Edit"_short_string);
- edit_menu.add_action(*m_copy_action);
- edit_menu.add_action(*m_cut_action);
- edit_menu.add_action(*m_paste_action);
- edit_menu.add_separator();
- edit_menu.add_action(*m_undo_action);
- edit_menu.add_action(*m_redo_action);
- edit_menu.add_separator();
- edit_menu.add_action(*m_run_script_action);
-
- auto& help_menu = window->add_menu("&Help"_short_string);
- help_menu.add_action(GUI::CommonActions::make_command_palette_action(window));
- help_menu.add_action(GUI::CommonActions::make_help_action([](auto&) {
+ })));
+
+ auto edit_menu = TRY(window->try_add_menu("&Edit"_short_string));
+ TRY(edit_menu->try_add_action(*m_copy_action));
+ TRY(edit_menu->try_add_action(*m_cut_action));
+ TRY(edit_menu->try_add_action(*m_paste_action));
+ TRY(edit_menu->try_add_separator());
+ TRY(edit_menu->try_add_action(*m_undo_action));
+ TRY(edit_menu->try_add_action(*m_redo_action));
+ TRY(edit_menu->try_add_separator());
+ TRY(edit_menu->try_add_action(*m_run_script_action));
+
+ auto help_menu = TRY(window->try_add_menu("&Help"_short_string));
+ TRY(help_menu->try_add_action(GUI::CommonActions::make_command_palette_action(window)));
+ TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
Desktop::Launcher::open(URL::create_with_file_scheme("/usr/share/man/man1/SQLStudio.md"), "/bin/Help");
- }));
- help_menu.add_action(GUI::CommonActions::make_about_action("SQL Studio", GUI::Icon::default_icon("app-sql-studio"sv), window));
+ })));
+ TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("SQL Studio", GUI::Icon::default_icon("app-sql-studio"sv), window)));
+ return {};
}
void MainWidget::open_new_script()
diff --git a/Userland/DevTools/SQLStudio/MainWidget.h b/Userland/DevTools/SQLStudio/MainWidget.h
index d17d4c4cbd..017923b5eb 100644
--- a/Userland/DevTools/SQLStudio/MainWidget.h
+++ b/Userland/DevTools/SQLStudio/MainWidget.h
@@ -22,7 +22,7 @@ class MainWidget : public GUI::Widget {
public:
virtual ~MainWidget() = default;
- void initialize_menu(GUI::Window*);
+ ErrorOr<void> initialize_menu(GUI::Window*);
void open_new_script();
void open_script_from_file(LexicalPath const&);
diff --git a/Userland/DevTools/SQLStudio/main.cpp b/Userland/DevTools/SQLStudio/main.cpp
index 4a892c8843..5689a33509 100644
--- a/Userland/DevTools/SQLStudio/main.cpp
+++ b/Userland/DevTools/SQLStudio/main.cpp
@@ -31,7 +31,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->set_title("SQL Studio");
auto main_widget = TRY(window->set_main_widget<MainWidget>());
- main_widget->initialize_menu(window);
+ TRY(main_widget->initialize_menu(window));
window->on_close_request = [&] {
if (main_widget->request_close())