[Bf-blender-cvs] [0d8f1414a21] blender-v3.0-release: Fix access to current preferences when version patching read preferences

Julian Eisel noreply at git.blender.org
Wed Nov 3 14:24:04 CET 2021


Commit: 0d8f1414a21a9c7a3498fd65ce5cd02673582eed
Author: Julian Eisel
Date:   Wed Nov 3 14:17:26 2021 +0100
Branches: blender-v3.0-release
https://developer.blender.org/rB0d8f1414a21a9c7a3498fd65ce5cd02673582eed

Fix access to current preferences when version patching read preferences

The version patch for 0cf9794c7ef0 was checking and setting a data name
using the macros for translation. These would access the current
preferences which can mismatch the ones currently being version patched.
See discussion in 0cf9794c7ef0 for details.

Don't handle translation in this version patch, which is more of a
"nice-to-have" version patch, no functionality depends on it.

===================================================================

M	source/blender/blenkernel/BKE_preferences.h
M	source/blender/blenkernel/intern/preferences.c
M	source/blender/blenloader/intern/versioning_userdef.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_preferences.h b/source/blender/blenkernel/BKE_preferences.h
index fce2d3178aa..fd4d13f4125 100644
--- a/source/blender/blenkernel/BKE_preferences.h
+++ b/source/blender/blenkernel/BKE_preferences.h
@@ -29,8 +29,8 @@ extern "C" {
 struct UserDef;
 struct bUserAssetLibrary;
 
-/** Name of the asset library added by default. */
-#define BKE_PREFS_ASSET_LIBRARY_DEFAULT_NAME DATA_("User Library")
+/** Name of the asset library added by default. Needs translation with `DATA_()` still. */
+#define BKE_PREFS_ASSET_LIBRARY_DEFAULT_NAME N_("User Library")
 
 struct bUserAssetLibrary *BKE_preferences_asset_library_add(struct UserDef *userdef,
                                                             const char *name,
diff --git a/source/blender/blenkernel/intern/preferences.c b/source/blender/blenkernel/intern/preferences.c
index 79a8b591f72..0a10601f751 100644
--- a/source/blender/blenkernel/intern/preferences.c
+++ b/source/blender/blenkernel/intern/preferences.c
@@ -121,7 +121,7 @@ void BKE_preferences_asset_library_default_add(UserDef *userdef)
   }
 
   bUserAssetLibrary *library = BKE_preferences_asset_library_add(
-      userdef, BKE_PREFS_ASSET_LIBRARY_DEFAULT_NAME, NULL);
+      userdef, DATA_(BKE_PREFS_ASSET_LIBRARY_DEFAULT_NAME), NULL);
 
   /* Add new "Default" library under '[doc_path]/Blender/Assets'. */
   BLI_path_join(
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 4234570af6c..3c470a7d3df 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -927,9 +927,13 @@ void blo_do_versions_userdef(UserDef *userdef)
   }
 
   if (!USER_VERSION_ATLEAST(300, 40)) {
-    /* Rename the default asset library from "Default" to "User Library" */
+    /* Rename the default asset library from "Default" to "User Library". This isn't bullet proof
+     * since it doesn't handle translations and ignores user changes. But this was an alpha build
+     * (experimental) feature and the name is just for display in the UI anyway. So it doesn't have
+     * to work perfectly at all. */
     LISTBASE_FOREACH (bUserAssetLibrary *, asset_library, &userdef->asset_libraries) {
-      if (STREQ(asset_library->name, DATA_("Default"))) {
+      /* Ignores translations, since that would depend on the current preferences (global `U`). */
+      if (STREQ(asset_library->name, "Default")) {
         BKE_preferences_asset_library_name_set(
             userdef, asset_library, BKE_PREFS_ASSET_LIBRARY_DEFAULT_NAME);
       }



More information about the Bf-blender-cvs mailing list