Cleanup: move theme versioning into own function
authorCampbell Barton <ideasman42@gmail.com>
Wed, 12 Sep 2018 09:58:37 +0000 (19:58 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 12 Sep 2018 09:59:28 +0000 (19:59 +1000)
source/blender/blenloader/intern/versioning_userdef.c

index 6ca7bba1ed2de03fee53ac6f72d8c1a782f80887..a55568129c57e6feaad5273180c770613d41dc08 100644 (file)
 
 #include "BLO_readfile.h"  /* Own include. */
 
+/* Disallow access to global userdef. */
 #define U (_error_)
 
+#define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST(userdef, ver, subver)
+
+static void do_versions_theme(UserDef *userdef, bTheme *btheme)
+{
+       if (!USER_VERSION_ATLEAST(280, 20)) {
+               memcpy(btheme, &U_theme_default, sizeof(*btheme));
+       }
+}
+
+#undef USER_VERSION_ATLEAST
+
+
 /* patching UserDef struct and Themes */
 void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
 {
@@ -323,4 +336,8 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
 #endif
        /* this timer uses U */
 // XXX reset_autosave();
+
+       for (bTheme *btheme = userdef->themes.first; btheme; btheme = btheme->next) {
+               do_versions_theme(userdef, btheme);
+       }
 }