From 5ec9654477dda09cf1f520a37d19f134eb12ad61 Mon Sep 17 00:00:00 2001
From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com>
Date: Wed, 10 May 2023 17:00:23 -0400
Subject: [PATCH] FontEditor: Propagate errors when loading GML
---
.../Applications/FontEditor/MainWidget.cpp | 18 ++++++++++++++++--
Userland/Applications/FontEditor/MainWidget.h | 13 +++----------
2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/Userland/Applications/FontEditor/MainWidget.cpp b/Userland/Applications/FontEditor/MainWidget.cpp
index 146855d882..1aaf12c5e9 100644
--- a/Userland/Applications/FontEditor/MainWidget.cpp
+++ b/Userland/Applications/FontEditor/MainWidget.cpp
@@ -59,6 +59,18 @@ static constexpr Array pangrams = {
"lazy dog"sv
};
+ErrorOr> MainWidget::try_create()
+{
+ auto main_widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) MainWidget()));
+ TRY(main_widget->create_widgets());
+ TRY(main_widget->create_actions());
+ TRY(main_widget->create_models());
+ TRY(main_widget->create_toolbars());
+ TRY(main_widget->create_undo_stack());
+
+ return main_widget;
+}
+
ErrorOr> MainWidget::create_preview_window()
{
auto window = TRY(GUI::Window::try_create(this));
@@ -433,9 +445,9 @@ ErrorOr MainWidget::create_undo_stack()
return {};
}
-MainWidget::MainWidget()
+ErrorOr MainWidget::create_widgets()
{
- load_from_gml(font_editor_window_gml).release_value_but_fixme_should_propagate_errors();
+ TRY(load_from_gml(font_editor_window_gml));
m_font_metadata_groupbox = find_descendant_of_type_named("font_metadata_groupbox");
m_unicode_block_container = find_descendant_of_type_named("unicode_block_container");
@@ -603,6 +615,8 @@ MainWidget::MainWidget()
GUI::Application::the()->on_action_leave = [this](GUI::Action&) {
m_statusbar->set_override_text({});
};
+
+ return {};
}
ErrorOr MainWidget::initialize(StringView path, RefPtr&& edited_font)
diff --git a/Userland/Applications/FontEditor/MainWidget.h b/Userland/Applications/FontEditor/MainWidget.h
index c3942cfb31..21ee57fe92 100644
--- a/Userland/Applications/FontEditor/MainWidget.h
+++ b/Userland/Applications/FontEditor/MainWidget.h
@@ -22,15 +22,7 @@ class GlyphEditorWidget;
class MainWidget final : public GUI::Widget {
C_OBJECT(MainWidget)
public:
- static ErrorOr> try_create()
- {
- NonnullRefPtr font_editor = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) MainWidget()));
- TRY(font_editor->create_actions());
- TRY(font_editor->create_models());
- TRY(font_editor->create_toolbars());
- TRY(font_editor->create_undo_stack());
- return font_editor;
- }
+ static ErrorOr> try_create();
virtual ~MainWidget() override = default;
@@ -58,8 +50,9 @@ public:
void set_show_system_emoji(bool);
private:
- MainWidget();
+ MainWidget() = default;
+ ErrorOr create_widgets();
ErrorOr create_actions();
ErrorOr create_models();
ErrorOr create_toolbars();