mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:37:35 +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:
parent
55a903911b
commit
4c732abed5
4 changed files with 29 additions and 13 deletions
|
@ -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>();
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ namespace HackStudio {
|
|||
class DebugInfoWidget final : public GUI::Widget {
|
||||
C_OBJECT(DebugInfoWidget)
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<DebugInfoWidget>> create();
|
||||
virtual ~DebugInfoWidget() override { }
|
||||
|
||||
void update_state(Debug::ProcessInspector&, PtraceRegisters const&);
|
||||
|
@ -34,7 +35,7 @@ public:
|
|||
|
||||
private:
|
||||
explicit DebugInfoWidget();
|
||||
void init_toolbar();
|
||||
ErrorOr<void> init_toolbar();
|
||||
|
||||
NonnullRefPtr<GUI::Widget> build_variables_tab();
|
||||
NonnullRefPtr<GUI::Widget> build_registers_tab();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue