mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 19:27:43 +00:00
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.
This commit is contained in:
parent
3c1ea2861b
commit
c044a556db
1 changed files with 8 additions and 4 deletions
|
@ -546,6 +546,11 @@ ErrorOr<void> MainWidget::initialize(String const& path, RefPtr<Gfx::BitmapFont>
|
||||||
{
|
{
|
||||||
if (m_edited_font == edited_font)
|
if (m_edited_font == edited_font)
|
||||||
return {};
|
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_path = path;
|
||||||
m_edited_font = edited_font;
|
m_edited_font = edited_font;
|
||||||
|
|
||||||
|
@ -592,10 +597,6 @@ ErrorOr<void> MainWidget::initialize(String const& path, RefPtr<Gfx::BitmapFont>
|
||||||
i++;
|
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();
|
update_statusbar();
|
||||||
|
|
||||||
deferred_invoke([this] {
|
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->set_focus(true);
|
||||||
m_glyph_map_widget->scroll_to_glyph(glyph);
|
m_glyph_map_widget->scroll_to_glyph(glyph);
|
||||||
m_glyph_editor_widget->set_glyph(glyph);
|
m_glyph_editor_widget->set_glyph(glyph);
|
||||||
|
|
||||||
|
VERIFY(window());
|
||||||
|
window()->set_modified(false);
|
||||||
update_title();
|
update_title();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue