From 7aa6444a65a2855483d68f3d9c0270b57aedeffc Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Wed, 21 Apr 2021 15:14:03 +0200 Subject: 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. --- source/blender/windowmanager/intern/wm_files.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'source/blender/windowmanager') 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) -- cgit v1.2.3