Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2021-01-26 07:08:28 +0300
committerCampbell Barton <ideasman42@gmail.com>2021-01-26 07:16:12 +0300
commitd55d95b04da42f120406678fc47deb00081f7285 (patch)
tree35eebc8147a366c805be46e12885a61716aa0dab /source/blender/windowmanager/intern/wm_files.c
parentbe262cf561293541b889a97026311adf3965a545 (diff)
WM: return success from WM_recover_last_session, minor cleanup
- Return success from WM_recover_last_session - Avoid setting global variables is already called in WM_file_read. While it didn't cause any problems, these assignments ran even when recovering the session failed to load the file. - Return OPERATOR_CANCELLED when the operator fails. Returning success is needed to fix T85011.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_files.c')
-rw-r--r--source/blender/windowmanager/intern/wm_files.c31
1 files changed, 9 insertions, 22 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index d179cc456f4..bfc3d7e1a5f 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -2549,35 +2549,22 @@ void WM_OT_revert_mainfile(wmOperatorType *ot)
/** \name Recover Last Session Operator
* \{ */
-void WM_recover_last_session(bContext *C, ReportList *reports)
+bool WM_recover_last_session(bContext *C, ReportList *reports)
{
char filepath[FILE_MAX];
-
BLI_join_dirfile(filepath, sizeof(filepath), BKE_tempdir_base(), BLENDER_QUIT_FILE);
- /* if reports==NULL, it's called directly without operator, we add a quick check here */
- if (reports || BLI_exists(filepath)) {
- G.fileflags |= G_FILE_RECOVER;
-
- wm_file_read_opwrap(C, filepath, reports, true);
-
- G.fileflags &= ~G_FILE_RECOVER;
-
- /* XXX bad global... fixme */
- Main *bmain = CTX_data_main(C);
- if (BKE_main_blendfile_path(bmain)[0] != '\0') {
- G.file_loaded = 1; /* prevents splash to show */
- }
- else {
- G.relbase_valid = 0;
- G.save_over = 0; /* start with save preference untitled.blend */
- }
- }
+ G.fileflags |= G_FILE_RECOVER;
+ const bool success = wm_file_read_opwrap(C, filepath, reports, true);
+ G.fileflags &= ~G_FILE_RECOVER;
+ return success;
}
static int wm_recover_last_session_exec(bContext *C, wmOperator *op)
{
- WM_recover_last_session(C, op->reports);
- return OPERATOR_FINISHED;
+ if (WM_recover_last_session(C, op->reports)) {
+ return OPERATOR_FINISHED;
+ }
+ return OPERATOR_CANCELLED;
}
void WM_OT_recover_last_session(wmOperatorType *ot)