From 09139e41ed4eaf4d9b8943e92b8604d979dbbc92 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 27 Oct 2020 18:21:16 +1100 Subject: Cleanup: simplify order of initialization with argument parsing Sub-systems that use directories from BKE_appdir needed to be initialized after parsing '--env-system-datafiles'. This meant the animation player needed to call IMB_init it's self. Avoid this complication by having a pass that can be used to setup the environment before Blender's resources are accessed. This reverts the workaround from 9ea345d1cf82f --- source/creator/creator.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'source/creator/creator.c') diff --git a/source/creator/creator.c b/source/creator/creator.c index 65610ea9b70..f9aea0af301 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -403,25 +403,30 @@ int main(int argc, * (such as '--version' & '--help') don't report leaks. */ MEM_use_memleak_detection(false); - BLI_argsParse(ba, 1, NULL, NULL); - - main_signal_setup(); + /* Parse environment handling arguments. */ + BLI_argsParse(ba, 0, NULL, NULL); #else /* Using preferences or user startup makes no sense for #WITH_PYTHON_MODULE. */ G.factory_startup = true; #endif - /* After parsing the first level of arguments as `--env-*` impact BKE_appdir behavior. */ + /* After parsing '0' level args such as `--env-*`, since they impact `BKE_appdir` behavior. */ BKE_appdir_init(); + /* Initialize sub-systems that use `BKE_appdir.h`. */ + IMB_init(); + +#ifndef WITH_PYTHON_MODULE + /* First test for background-mode (#Global.background) */ + BLI_argsParse(ba, 1, NULL, NULL); + + main_signal_setup(); +#endif + /* After parsing number of threads argument. */ BLI_task_scheduler_init(); - /* After parsing `--env-system-datafiles` which control where paths are searched - * (color-management) uses BKE_appdir to initialize. */ - IMB_init(); - #ifdef WITH_FFMPEG IMB_ffmpeg_init(); #endif -- cgit v1.2.3