Page MenuHome

Fix T86566: Do Not Close if File Cannot Be Saved
ClosedPublic

Authored by Harley Acheson (harley) on Mar 15 2021, 2:29 AM.
Tokens
"Like" token, awarded by gilberto_rodrigues."Like" token, awarded by razed."Like" token, awarded by Tetone."Like" token, awarded by manitwo.

Details

Summary

Open up a blend file that is read-only, make changes, and then try to close it. The Quit Close dialog will ask you if you want to save before closing. But you will briefly see an error message flash before Blender closes without saving your changes.

Clicking that "Save" Button starts a process that will end with a "post_action" that will close blender when it is done. The process calls operator WM_OT_save_mainfile but unfortunately the result of wm_save_as_mainfile_exec() is not examined to see if an error occurred. It could return OPERATOR_FINISHED if everything saved, or OPERATOR_CANCELLED if there is an error, but the post_action is called regardless.

The patch just makes sure to only allow the post_action to be called (closing blender) if the result of WM_OT_save_mainfile is OPERATOR_FINISHED. So if you say "Yes, I want to save" but it is not able to then blender will remain open and you can read the error message explaining what happened. At that point you can "save as" or close without saving.

Following shows how it looks when saving a file that is read-only after this patch is applied:

Diff Detail

Repository
rB Blender

Event Timeline

Slight change in logic in case execute_callback is false before it gets here.

updating to current state of master

Julian Eisel (Severin) requested changes to this revision.Apr 19 2021, 4:59 PM

This is a good change I think, one thing to correct.

source/blender/windowmanager/intern/wm_files.c
3273–3277

Operator return values are bit-flags, e.g. it's not unusual to return OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH. So should do bit wise AND here.

This revision now requires changes to proceed.Apr 19 2021, 4:59 PM
Harley Acheson (harley) edited the summary of this revision. (Show Details)

Updated to incorporate a suggestion by @Julian Eisel (Severin), checking for OPERATOR_CANCELLED with &

This revision is now accepted and ready to land.Apr 23 2021, 5:02 AM