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

HackStudio: Add a factory function for DebugInfoWidget

Thanks to this patch we now do error propagation in the DebugInfoWidget
creation and as a result we get rid of 4 FIXMEs :)
This commit is contained in:
Baitinq 2022-12-16 02:00:56 +01:00 committed by Andreas Kling
parent 55a903911b
commit 4c732abed5
4 changed files with 29 additions and 13 deletions

View file

@ -22,21 +22,21 @@
namespace HackStudio {
void DebugInfoWidget::init_toolbar()
ErrorOr<void> DebugInfoWidget::init_toolbar()
{
m_continue_action = GUI::Action::create("Continue", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-continue.png"sv).release_value_but_fixme_should_propagate_errors(), [](auto&) {
m_continue_action = GUI::Action::create("Continue", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-continue.png"sv)), [](auto&) {
Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::Continue);
});
m_singlestep_action = GUI::Action::create("Step Over", { Mod_None, Key_F10 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-over.png"sv).release_value_but_fixme_should_propagate_errors(), [](auto&) {
m_singlestep_action = GUI::Action::create("Step Over", { Mod_None, Key_F10 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-over.png"sv)), [](auto&) {
Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceStepOver);
});
m_step_in_action = GUI::Action::create("Step In", { Mod_None, Key_F11 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-in.png"sv).release_value_but_fixme_should_propagate_errors(), [](auto&) {
m_step_in_action = GUI::Action::create("Step In", { Mod_None, Key_F11 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-in.png"sv)), [](auto&) {
Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceSingleStep);
});
m_step_out_action = GUI::Action::create("Step Out", { Mod_Shift, Key_F11 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-out.png"sv).release_value_but_fixme_should_propagate_errors(), [](auto&) {
m_step_out_action = GUI::Action::create("Step Out", { Mod_Shift, Key_F11 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-out.png"sv)), [](auto&) {
Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceStepOut);
});
@ -46,14 +46,25 @@ void DebugInfoWidget::init_toolbar()
m_toolbar->add_action(*m_step_out_action);
set_debug_actions_enabled(false);
return {};
}
ErrorOr<NonnullRefPtr<DebugInfoWidget>> DebugInfoWidget::create()
{
auto debuginfo_widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) DebugInfoWidget));
auto& toolbar_container = debuginfo_widget->add<GUI::ToolbarContainer>();
debuginfo_widget->m_toolbar = toolbar_container.add<GUI::Toolbar>();
TRY(debuginfo_widget->init_toolbar());
return debuginfo_widget;
}
DebugInfoWidget::DebugInfoWidget()
{
set_layout<GUI::VerticalBoxLayout>();
auto& toolbar_container = add<GUI::ToolbarContainer>();
m_toolbar = toolbar_container.add<GUI::Toolbar>();
init_toolbar();
auto& bottom_box = add<GUI::Widget>();
bottom_box.set_layout<GUI::HorizontalBoxLayout>();