diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c index d41a2ff448c..4aa26806506 100644 --- a/source/creator/creator_args.c +++ b/source/creator/creator_args.c @@ -2039,8 +2039,7 @@ static int arg_handle_python_file_run(int argc, const char **argv, void *data) BPY_CTX_SETUP(ok = BPY_run_filepath(C, filepath, NULL)); if (!ok && app_state.exit_code_on_error.python) { fprintf(stderr, "\nError: script failed, file: '%s', exiting.\n", argv[1]); - BPY_python_end(); - exit(app_state.exit_code_on_error.python); + WM_exit(C, app_state.exit_code_on_error.python); } return 1; } @@ -2079,8 +2078,7 @@ static int arg_handle_python_text_run(int argc, const char **argv, void *data) if (!ok && app_state.exit_code_on_error.python) { fprintf(stderr, "\nError: script failed, text: '%s', exiting.\n", argv[1]); - BPY_python_end(); - exit(app_state.exit_code_on_error.python); + WM_exit(C, app_state.exit_code_on_error.python); } return 1; @@ -2109,8 +2107,7 @@ static int arg_handle_python_expr_run(int argc, const char **argv, void *data) BPY_CTX_SETUP(ok = BPY_run_string_exec(C, NULL, argv[1])); if (!ok && app_state.exit_code_on_error.python) { fprintf(stderr, "\nError: script failed, expr: '%s', exiting.\n", argv[1]); - BPY_python_end(); - exit(app_state.exit_code_on_error.python); + WM_exit(C, app_state.exit_code_on_error.python); } return 1; } @@ -2549,6 +2546,8 @@ void main_args_setup(bContext *C, bArgs *ba, bool all) BLI_args_add_case(ba, "-setaudio", 1, NULL, 0, CB(arg_handle_audio_set), NULL); /* Pass: Processing Arguments. */ + /* NOTE: Use #WM_exit for these callbacks, not `exit()` + * so temporary files are properly cleaned up. */ BLI_args_pass_set(ba, ARG_PASS_FINAL); BLI_args_add(ba, "-f", "--render-frame", CB(arg_handle_render_frame), C); BLI_args_add(ba, "-a", "--render-anim", CB(arg_handle_render_animation), C); diff --git a/source/creator/creator_intern.h b/source/creator/creator_intern.h index 3a49e6c03ec..04ea5687587 100644 --- a/source/creator/creator_intern.h +++ b/source/creator/creator_intern.h @@ -67,7 +67,12 @@ enum { /** Currently use for audio devices. */ ARG_PASS_SETTINGS_FORCE = 4, - /** Actions & fall back to loading blend file. */ + /** + * Actions & fall back to loading blend file. + * + * \note arguments in the final pass must use #WM_exit instead of `exit()` environment is + * properly shut-down (temporary directory deleted, etc). + */ ARG_PASS_FINAL = 5, };