diff options
author | Gunnar Beutner <gbeutner@serenityos.org> | 2021-06-22 19:22:26 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-22 22:56:22 +0200 |
commit | 928364e10251e0faff36559630b7d0f1f907cb7a (patch) | |
tree | 4d67a7e4e34a01fc237a285744723e3c86376872 /Userland | |
parent | 92fdc5bd69afc346ef181104617ddc29974c6576 (diff) | |
download | serenity-928364e10251e0faff36559630b7d0f1f907cb7a.zip |
TextEditor: Don't open files when the user cancelled saving changes
Steps to reproduce:
1. Start TextEditor and make some changes to the document.
2. Try to open an existing file.
3. When prompted choose to save the changes to the existing document.
4. Close the file picker by clicking 'Cancel'.
5. Note how the file was opened anyway and your changes were lost.
Same applies to the 'New File' action.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Applications/TextEditor/MainWidget.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Applications/TextEditor/MainWidget.cpp b/Userland/Applications/TextEditor/MainWidget.cpp index 83eef1b554..3bc77d7492 100644 --- a/Userland/Applications/TextEditor/MainWidget.cpp +++ b/Userland/Applications/TextEditor/MainWidget.cpp @@ -249,7 +249,7 @@ MainWidget::MainWidget() 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::ExecCancel) + if (save_document_first_result != GUI::Dialog::ExecResult::ExecNo && editor().document().is_modified()) return; } @@ -268,7 +268,7 @@ MainWidget::MainWidget() 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::ExecCancel) + if (save_document_first_result != GUI::Dialog::ExecResult::ExecNo && editor().document().is_modified()) return; } |