Skip to content

Commit

Permalink
HexEditor: Prompt the user to save changes when opening a file
Browse files Browse the repository at this point in the history
  • Loading branch information
gunnarbeutner authored and awesomekling committed Jun 23, 2021
1 parent 5edc0d1 commit b246221
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Userland/Applications/HexEditor/HexEditorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ HexEditorWidget::HexEditorWidget()
if (!open_path.has_value())
return;

if (m_document_dirty) {
auto save_document_first_result = GUI::MessageBox::show(window(), "Save changes to current document first?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel);
if (save_document_first_result == GUI::Dialog::ExecResult::ExecYes)
m_save_action->activate();
if (save_document_first_result != GUI::Dialog::ExecResult::ExecNo && m_document_dirty)
return;
}

open_file(open_path.value());
});

Expand Down

0 comments on commit b246221

Please sign in to comment.