diff options
author | thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> | 2022-07-30 07:25:39 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-08-04 02:54:00 +0200 |
commit | c044a556db66198e40e241aac2dff72c24a0c17d (patch) | |
tree | 304b0bcafa1756ccc59dcb4f38806ac9808e4baa /Userland/Applications | |
parent | 3c1ea2861b6885fb43272da8de76bf3cb4913472 (diff) | |
download | serenity-c044a556db66198e40e241aac2dff72c24a0c17d.zip |
FontEditor: Let editor recover from failed initializations
Fail early during font initialization and leave the editor in a
valid state in case of errors during UndoSelection creation.
Diffstat (limited to 'Userland/Applications')
-rw-r--r-- | Userland/Applications/FontEditor/MainWidget.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Userland/Applications/FontEditor/MainWidget.cpp b/Userland/Applications/FontEditor/MainWidget.cpp index 2ff0b44431..ebf53da591 100644 --- a/Userland/Applications/FontEditor/MainWidget.cpp +++ b/Userland/Applications/FontEditor/MainWidget.cpp @@ -546,6 +546,11 @@ ErrorOr<void> MainWidget::initialize(String const& path, RefPtr<Gfx::BitmapFont> { if (m_edited_font == edited_font) return {}; + + auto selection = m_glyph_map_widget->selection().normalized(); + m_undo_selection = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) UndoSelection(selection.start(), selection.size(), m_glyph_map_widget->active_glyph(), *edited_font))); + m_undo_stack->clear(); + m_path = path; m_edited_font = edited_font; @@ -592,10 +597,6 @@ ErrorOr<void> MainWidget::initialize(String const& path, RefPtr<Gfx::BitmapFont> i++; } - auto selection = m_glyph_map_widget->selection().normalized(); - m_undo_selection = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) UndoSelection(selection.start(), selection.size(), m_glyph_map_widget->active_glyph(), *m_edited_font))); - m_undo_stack->clear(); - update_statusbar(); deferred_invoke([this] { @@ -603,6 +604,9 @@ ErrorOr<void> MainWidget::initialize(String const& path, RefPtr<Gfx::BitmapFont> m_glyph_map_widget->set_focus(true); m_glyph_map_widget->scroll_to_glyph(glyph); m_glyph_editor_widget->set_glyph(glyph); + + VERIFY(window()); + window()->set_modified(false); update_title(); }); |