[Bf-blender-cvs] [7aa6444a65a] master: UI: Use proper close file dialog for "Restore Last Session"

Julian Eisel noreply at git.blender.org
Wed Apr 21 15:18:12 CEST 2021


Commit: 7aa6444a65a2855483d68f3d9c0270b57aedeffc
Author: Julian Eisel
Date:   Wed Apr 21 15:14:03 2021 +0200
Branches: master
https://developer.blender.org/rB7aa6444a65a2855483d68f3d9c0270b57aedeffc

UI: Use proper close file dialog for "Restore Last Session"

Was showing a simple confirm dialog, even if the file didn't contain
unsaved changes. The confirm dialog would also show up when choosing
"Restore Last Session" from the splash screen right after startup, which
is weird.

Instead show the proper file closing dialog that allows saving, but only
if there are actually unsaved changes.

===================================================================

M	source/blender/windowmanager/intern/wm_files.c

===================================================================

diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index c1fdb005232..614824ef7e2 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -2619,12 +2619,25 @@ static int wm_recover_last_session_exec(bContext *C, wmOperator *op)
   return OPERATOR_CANCELLED;
 }
 
-static int wm_recover_last_session_invoke(bContext *C, wmOperator *op, const wmEvent *event)
+static void wm_recover_last_session_after_dialog_callback(bContext *C, void *user_data)
+{
+  WM_operator_name_call_with_properties(
+      C, "WM_OT_recover_last_session", WM_OP_EXEC_DEFAULT, (IDProperty *)user_data);
+}
+
+static int wm_recover_last_session_invoke(bContext *C,
+                                          wmOperator *op,
+                                          const wmEvent *UNUSED(event))
 {
   /* Keep the current setting instead of using the preferences since a file selector
    * doesn't give us the option to change the setting. */
   wm_open_init_use_scripts(op, false);
-  return WM_operator_confirm(C, op, event);
+
+  if (wm_operator_close_file_dialog_if_needed(
+          C, op, wm_recover_last_session_after_dialog_callback)) {
+    return OPERATOR_INTERFACE;
+  }
+  return wm_recover_last_session_exec(C, op);
 }
 
 void WM_OT_recover_last_session(wmOperatorType *ot)



More information about the Bf-blender-cvs mailing list