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.
This commit is contained in:
parent
92fdc5bd69
commit
928364e102
Notes:
sideshowbarker
2024-07-18 11:38:41 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/928364e1025 Pull-request: https://github.com/SerenityOS/serenity/pull/8206
1 changed files with 2 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue