1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:07:45 +00:00

HexEditor: Handle some errors inside the editor

Specifically, the ones HexEditor::did_complete_action possibly raised in
case creating an undo stack entry or pushing it onto the undo stack
fails. In this case, an error popup is displayed and the modifications
are undone.

This removes 2 FIXMEs inside the code :^)
This commit is contained in:
Arda Cinar 2022-12-07 21:32:07 +03:00 committed by Andrew Kaster
parent d3ce9cf8f6
commit 2dd7fa2d44
3 changed files with 60 additions and 29 deletions

View file

@ -245,7 +245,9 @@ HexEditorWidget::HexEditorWidget()
DeprecatedString value;
if (GUI::InputBox::show(window(), value, "Fill byte (hex):"sv, "Fill Selection"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) {
auto fill_byte = strtol(value.characters(), nullptr, 16);
m_editor->fill_selection(fill_byte);
auto result = m_editor->fill_selection(fill_byte);
if (result.is_error())
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("{}", result.error()));
}
});
m_fill_selection_action->set_enabled(false);