FIX: Editor closes when clicking cancel in a save dialog prompt (UUM-134748)#2366
FIX: Editor closes when clicking cancel in a save dialog prompt (UUM-134748)#2366Darren-Kelly-Unity wants to merge 4 commits intodevelopfrom
Conversation
…a save dialog prompt.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr |
PR Code Suggestions ✨No code suggestions found for the PR. |
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## develop #2366 +/- ##
===========================================
- Coverage 77.90% 77.89% -0.02%
===========================================
Files 476 476
Lines 97613 97642 +29
===========================================
+ Hits 76048 76056 +8
- Misses 21565 21586 +21 Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
MorganHoarau
left a comment
There was a problem hiding this comment.
Minor suggestions, but does the work!
| private bool HandleOnDestroyIfApplicationIsAllowedToQuit(bool rebuildUIOnCancel) | ||
| { | ||
| // Do we have unsaved changes that we need to ask the user to save or discard? | ||
| if (!m_IsDirty) |
There was a problem hiding this comment.
Code could be simplify.
| if (!m_IsDirty) | |
| // Early out if asset up to date or editor closing. | |
| if (!m_IsDirty || m_IsEditorQuitting) |
| /// Shows a dialog when trying to close an input asset without saving changes. | ||
| /// </summary> | ||
| /// <returns> Returns true if you should allow the Unity Editor to close. </returns> | ||
| private bool HandleOnDestroyIfApplicationIsAllowedToQuit(bool rebuildUIOnCancel) |
There was a problem hiding this comment.
I'm having issue with the semantic mismatch of what the method is doing versus what it is returning.
The method is executing a command (should return void) but returns a query (return a value).
What about a change of signature:
| private bool HandleOnDestroyIfApplicationIsAllowedToQuit(bool rebuildUIOnCancel) | |
| private bool CanCloseWindow(bool promptIfDirty, bool rebuildUIOnCancel) |
Or
| private bool HandleOnDestroyIfApplicationIsAllowedToQuit(bool rebuildUIOnCancel) | |
| private bool CheckCanCloseAndPromptIfDirty(bool rebuildUIOnCancel) |
| /// <summary> | ||
| /// Shows a dialog when trying to close an input asset without saving changes. | ||
| /// </summary> | ||
| /// <returns> Returns true if you should allow the Unity Editor to close. </returns> |
There was a problem hiding this comment.
| /// <returns> Returns true if you should allow the Unity Editor to close. </returns> | |
| /// <param name="rebuildUIOnCancel">If true, reopens the editor window when user cancels.</param> | |
| /// <returns> Returns true if you should allow the Unity Editor to close. </returns> |
Description
When there is a pending change that could be saved a dialog is prompted asking if you would like to save, don't save or cancel the closing of Unity.
When clicking cancel Unity would close anyway without saving the asset.
Ticket:
https://jira.unity3d.com/browse/UUM-134748
Testing status & QA
Manually tested, not easy to add an automated test for.
How to reproduce:
Overall Product Risks
Comments to reviewers
I tried to re-use existing code by extending the method, I am not sure about the naming, let me know what you think.
Checklist
Before review:
Changed,Fixed,Addedsections.Area_CanDoX,Area_CanDoX_EvenIfYIsTheCase,Area_WhenIDoX_AndYHappens_ThisIsTheResult.During merge:
NEW: ___.FIX: ___.DOCS: ___.CHANGE: ___.RELEASE: 1.1.0-preview.3.