diff --git a/source/blender/windowmanager/intern/wm_playanim.cc b/source/blender/windowmanager/intern/wm_playanim.cc index fe568e17e94..8f329e8253d 100644 --- a/source/blender/windowmanager/intern/wm_playanim.cc +++ b/source/blender/windowmanager/intern/wm_playanim.cc @@ -1712,6 +1712,11 @@ static bool wm_main_playanim_intern(int argc, const char **argv, PlayArgs *args_ ps.font_id = -1; + IMB_init(); +#ifdef WITH_FFMPEG + IMB_ffmpeg_init(); +#endif + STRNCPY(ps.display_ctx.display_settings.display_device, IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE)); IMB_colormanagement_init_default_view_settings(&ps.display_ctx.view_settings, @@ -2145,7 +2150,8 @@ static bool wm_main_playanim_intern(int argc, const char **argv, PlayArgs *args_ BLF_exit(); /* NOTE: Must happen before GPU Context destruction as GPU resources are released via - * Color Management module. Must be re-initialized in the case of drag & drop. */ + * Color Management module. + * NOTE: there is no #IMB_ffmpeg_exit. */ IMB_exit(); if (ps.ghost_data.gpu_context) { @@ -2161,9 +2167,6 @@ static bool wm_main_playanim_intern(int argc, const char **argv, PlayArgs *args_ /* Early exit, IMB and BKE should be exited only in end. */ if (ps.argv_next) { - /* Ensure drag & drop runs with a valid IMB state. */ - IMB_init(); - args_next->argc = ps.argc_next; args_next->argv = ps.argv_next; return true; diff --git a/source/creator/creator.cc b/source/creator/creator.cc index 75562a114dc..7e6815ee286 100644 --- a/source/creator/creator.cc +++ b/source/creator/creator.cc @@ -486,16 +486,23 @@ int main(int argc, /* After parsing number of threads argument. */ BLI_task_scheduler_init(); - /* Initialize sub-systems that use `BKE_appdir.h`. */ - IMB_init(); - #ifndef WITH_PYTHON_MODULE - /* First test for background-mode (#Global.background) */ + /* The settings pass includes: + * - Background-mode assignment (#Global.background), checked by other subsystems + * which may be skipped in background mode. + * - The animation player may be launched which takes over argument passing, + * initializes the sub-systems it needs which have not yet been started. + * The animation player will call `exit(..)` too, so code after this call + * never runs when it's invoked. + * - All the `--debug-*` flags. + */ BLI_args_parse(ba, ARG_PASS_SETTINGS, nullptr, nullptr); main_signal_setup(); #endif + /* Must be initialized after #BKE_appdir_init to account for color-management paths. */ + IMB_init(); #ifdef WITH_FFMPEG /* Keep after #ARG_PASS_SETTINGS since debug flags are checked. */ IMB_ffmpeg_init(); diff --git a/source/creator/creator_args.cc b/source/creator/creator_args.cc index 1b2f2973509..502f7f37267 100644 --- a/source/creator/creator_args.cc +++ b/source/creator/creator_args.cc @@ -1389,11 +1389,6 @@ static int arg_handle_playback_mode(int argc, const char **argv, void * /*data*/ { /* Ignore the animation player if `-b` was given first. */ if (G.background == 0) { -# ifdef WITH_FFMPEG - /* Setup FFmpeg with current debug flags. */ - IMB_ffmpeg_init(); -# endif - /* Skip this argument (`-a`). */ WM_main_playanim(argc - 1, argv + 1);