Cleanup: run UserDef versioning from readfile.c

Now versioning UserDef is run in readfile.c,
as is done for other Blender data.

Previously versioning was mixed with other run-time initialization,
so it needed to be called later by the window manager.
This commit is contained in:
Campbell Barton 2020-10-02 23:23:57 +10:00
parent 15a9579a03
commit e255040c77
Notes: blender-bot 2023-02-14 06:00:45 +01:00
Referenced by commit 0bf12cb025, Fix error in recent change "run UserDef versioning from readfile.c"
Referenced by issue #81405, Cycles is not enabled by default on recent builds
5 changed files with 21 additions and 26 deletions

View File

@ -6883,15 +6883,15 @@ static void link_global(FileData *fd, BlendFileData *bfd)
/** \name Versioning
* \{ */
/* initialize userdef with non-UI dependency stuff */
/* other initializers (such as theme color defaults) go to resources.c */
static void do_versions_userdef(FileData *fd, BlendFileData *bfd)
static void do_versions_userdef(FileData *UNUSED(fd), BlendFileData *bfd)
{
UserDef *user = bfd->user;
if (user == NULL) {
return;
}
BLO_version_defaults_userpref_blend(user);
}
static void do_versions(FileData *fd, Library *lib, Main *main)

View File

@ -7061,11 +7061,8 @@ void UI_init(void)
/* after reading userdef file */
void UI_init_userdef(void)
{
/* fix saved themes */
init_userdef_do_versions();
/* Initialize UI variables from values set in the preferences. */
uiStyleInit();
BLO_sanitize_experimental_features_userpref_blend(&U);
}
void UI_reinit_font(void)

View File

@ -993,7 +993,6 @@ void icon_draw_rect_input(
float x, float y, int w, int h, float alpha, short event_type, short event_value);
/* resources.c */
void init_userdef_do_versions(void);
void ui_resources_init(void);
void ui_resources_free(void);

View File

@ -1499,18 +1499,3 @@ void UI_make_axis_color(const uchar src_col[3], uchar dst_col[3], const char axi
break;
}
}
/* patching UserDef struct and Themes */
void init_userdef_do_versions(void)
{
BLO_version_defaults_userpref_blend(&U);
if (STREQ(U.tempdir, "/")) {
BKE_tempdir_system_init(U.tempdir);
}
/* Not versioning, just avoid errors. */
#ifndef WITH_CYCLES
BKE_addon_remove_safe(&U.addons, "cycles");
#endif
}

View File

@ -69,6 +69,7 @@
#include "DNA_windowmanager_types.h"
#include "DNA_workspace_types.h"
#include "BKE_addon.h"
#include "BKE_appdir.h"
#include "BKE_autoexec.h"
#include "BKE_blender.h"
@ -388,10 +389,18 @@ static void wm_window_match_do(bContext *C,
/** \name Preferences Initialization & Versioning
* \{ */
/* in case UserDef was read, we re-initialize all, and do versioning */
/**
* In case #UserDef was read, re-initialize values that depend on it.
*/
static void wm_init_userdef(Main *bmain)
{
/* versioning is here */
/* Not versioning, just avoid errors. */
#ifndef WITH_CYCLES
BKE_addon_remove_safe(&U.addons, "cycles");
#else
UNUSED_VARS(BKE_addon_remove_safe);
#endif
UI_init_userdef();
/* needed so loading a file from the command line respects user-pref T26156. */
@ -406,11 +415,16 @@ static void wm_init_userdef(Main *bmain)
MEM_CacheLimiter_set_maximum(((size_t)U.memcachelimit) * 1024 * 1024);
BKE_sound_init(bmain);
/* update tempdir from user preferences */
if (STREQ(U.tempdir, "/")) {
BKE_tempdir_system_init(U.tempdir);
}
/* Update `U.tempdir` from user preferences. */
BKE_tempdir_init(U.tempdir);
/* Update tablet API preference. */
WM_init_tablet_api();
BLO_sanitize_experimental_features_userpref_blend(&U);
}
/* return codes */