Fix color-management ignoring the data-path command line value
Initialize ImBuf (and color-management) after passing arguments that set environment variables such as `--env-system-datapath` This also fixes a bug where BKE_appdir logging failed since it was called before the `--log` argument was passed. Add asserts so this doesn't happen again.
This commit is contained in:
@@ -25,6 +25,8 @@ extern "C" {
|
|||||||
|
|
||||||
struct ListBase;
|
struct ListBase;
|
||||||
|
|
||||||
|
void BKE_appdir_init(void);
|
||||||
|
|
||||||
/* note on naming: typical _get() suffix is omitted here,
|
/* note on naming: typical _get() suffix is omitted here,
|
||||||
* since its the main purpose of the API. */
|
* since its the main purpose of the API. */
|
||||||
const char *BKE_appdir_folder_default(void);
|
const char *BKE_appdir_folder_default(void);
|
||||||
|
|||||||
@@ -83,6 +83,35 @@ static char btempdir_session[FILE_MAX] = "";
|
|||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
|
/* -------------------------------------------------------------------- */
|
||||||
|
/** \name Initialization
|
||||||
|
* \{ */
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
static bool is_appdir_init = false;
|
||||||
|
# define ASSERT_IS_INIT() BLI_assert(is_appdir_init)
|
||||||
|
#else
|
||||||
|
# define ASSERT_IS_INIT() ((void)0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sanity check to ensure correct API use in debug mode.
|
||||||
|
*
|
||||||
|
* Run this once the first level of arguments has been passed so we can be sure
|
||||||
|
* `--env-system-datafiles`, and other `--env-*` arguments has been passed.
|
||||||
|
*
|
||||||
|
* Without this any callers to this module that run early on,
|
||||||
|
* will miss out on changes from parsing arguments.
|
||||||
|
*/
|
||||||
|
void BKE_appdir_init(void)
|
||||||
|
{
|
||||||
|
#ifndef NDEBUG
|
||||||
|
is_appdir_init = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/** \} */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
/** \name Internal Utilities
|
/** \name Internal Utilities
|
||||||
* \{ */
|
* \{ */
|
||||||
@@ -198,6 +227,8 @@ static bool test_path(char *targetpath,
|
|||||||
const char *folder_name,
|
const char *folder_name,
|
||||||
const char *subfolder_name)
|
const char *subfolder_name)
|
||||||
{
|
{
|
||||||
|
ASSERT_IS_INIT();
|
||||||
|
|
||||||
/* Only the last argument should be NULL. */
|
/* Only the last argument should be NULL. */
|
||||||
BLI_assert(!(folder_name == NULL && (subfolder_name != NULL)));
|
BLI_assert(!(folder_name == NULL && (subfolder_name != NULL)));
|
||||||
BLI_path_join(targetpath, targetpath_len, path_base, folder_name, subfolder_name, NULL);
|
BLI_path_join(targetpath, targetpath_len, path_base, folder_name, subfolder_name, NULL);
|
||||||
@@ -231,6 +262,8 @@ static bool test_path(char *targetpath,
|
|||||||
*/
|
*/
|
||||||
static bool test_env_path(char *path, const char *envvar, const bool check_is_dir)
|
static bool test_env_path(char *path, const char *envvar, const bool check_is_dir)
|
||||||
{
|
{
|
||||||
|
ASSERT_IS_INIT();
|
||||||
|
|
||||||
const char *env_path = envvar ? BLI_getenv(envvar) : NULL;
|
const char *env_path = envvar ? BLI_getenv(envvar) : NULL;
|
||||||
if (!env_path) {
|
if (!env_path) {
|
||||||
return false;
|
return false;
|
||||||
@@ -810,6 +843,7 @@ void BKE_appdir_program_path_init(const char *argv0)
|
|||||||
*/
|
*/
|
||||||
const char *BKE_appdir_program_path(void)
|
const char *BKE_appdir_program_path(void)
|
||||||
{
|
{
|
||||||
|
BLI_assert(bprogname[0]);
|
||||||
return bprogname;
|
return bprogname;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -818,6 +852,7 @@ const char *BKE_appdir_program_path(void)
|
|||||||
*/
|
*/
|
||||||
const char *BKE_appdir_program_dir(void)
|
const char *BKE_appdir_program_dir(void)
|
||||||
{
|
{
|
||||||
|
BLI_assert(bprogdir[0]);
|
||||||
return bprogdir;
|
return bprogdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -826,6 +861,8 @@ bool BKE_appdir_program_python_search(char *fullpath,
|
|||||||
const int version_major,
|
const int version_major,
|
||||||
const int version_minor)
|
const int version_minor)
|
||||||
{
|
{
|
||||||
|
ASSERT_IS_INIT();
|
||||||
|
|
||||||
#ifdef PYTHON_EXECUTABLE_NAME
|
#ifdef PYTHON_EXECUTABLE_NAME
|
||||||
/* Passed in from the build-systems 'PYTHON_EXECUTABLE'. */
|
/* Passed in from the build-systems 'PYTHON_EXECUTABLE'. */
|
||||||
const char *python_build_def = STRINGIFY(PYTHON_EXECUTABLE_NAME);
|
const char *python_build_def = STRINGIFY(PYTHON_EXECUTABLE_NAME);
|
||||||
|
|||||||
@@ -377,7 +377,6 @@ int main(int argc,
|
|||||||
BKE_blender_globals_init(); /* blender.c */
|
BKE_blender_globals_init(); /* blender.c */
|
||||||
|
|
||||||
BKE_idtype_init();
|
BKE_idtype_init();
|
||||||
IMB_init();
|
|
||||||
BKE_cachefiles_init();
|
BKE_cachefiles_init();
|
||||||
BKE_images_init();
|
BKE_images_init();
|
||||||
BKE_modifier_init();
|
BKE_modifier_init();
|
||||||
@@ -413,9 +412,16 @@ int main(int argc,
|
|||||||
G.factory_startup = true;
|
G.factory_startup = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* After parsing the first level of arguments as `--env-*` impact BKE_appdir behavior. */
|
||||||
|
BKE_appdir_init();
|
||||||
|
|
||||||
/* After parsing number of threads argument. */
|
/* After parsing number of threads argument. */
|
||||||
BLI_task_scheduler_init();
|
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
|
#ifdef WITH_FFMPEG
|
||||||
IMB_ffmpeg_init();
|
IMB_ffmpeg_init();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user