Fix for mixup in startup.blend data init when userprefs.blend was missing
authorCampbell Barton <ideasman42@gmail.com>
Wed, 23 Jul 2014 10:20:59 +0000 (20:20 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 23 Jul 2014 10:23:05 +0000 (20:23 +1000)
Rename UI_init_userdef_factory to BLO_update_defaults_userpref_blend
This closely matches BLO_update_defaults_startup_blend so makes sense for them to be together.

source/blender/blenkernel/BKE_library.h
source/blender/blenkernel/intern/library.c
source/blender/blenloader/BLO_readfile.h
source/blender/blenloader/intern/versioning_defaults.c
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/resources.c
source/blender/windowmanager/intern/wm_files.c

index 0c7af12edc84021fda4dfd265e97ff8230ece8f6..1d37f9e64e159e78e87baaa89713dc3a57f33ca3 100644 (file)
@@ -104,6 +104,7 @@ void test_idbutton(char *name);
 
 void BKE_library_make_local(struct Main *bmain, struct Library *lib, bool untagged_only);
 
+struct ID *BKE_libblock_find_name_ex(struct Main *bmain, const short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 struct ID *BKE_libblock_find_name(const short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
 
 void set_free_windowmanager_cb(void (*func)(struct bContext *, struct wmWindowManager *) );
index 8e07564dec490c17046cd97ac38c29ba52e75892..515287de336bc8b16e6b53e4f7e32745719ab11a 100644 (file)
@@ -1150,14 +1150,17 @@ void BKE_main_unlock(struct Main *bmain)
 }
 
 /* ***************** ID ************************ */
-
-
-ID *BKE_libblock_find_name(const short type, const char *name)      /* type: "OB" or "MA" etc */
+ID *BKE_libblock_find_name_ex(struct Main *bmain, const short type, const char *name)
 {
-       ListBase *lb = which_libbase(G.main, type);
+       ListBase *lb = which_libbase(bmain, type);
        BLI_assert(lb != NULL);
        return BLI_findstring(lb, name, offsetof(ID, name) + 2);
 }
+ID *BKE_libblock_find_name(const short type, const char *name)
+{
+       return BKE_libblock_find_name_ex(G.main, type, name);
+}
+
 
 void id_sort_by_name(ListBase *lb, ID *id)
 {
index 4fb983c119b20e268efe0333f94ade04c7dd4d8d..4b7b9cecb17f37a4919007f4e7ca5150353ca816 100644 (file)
@@ -275,7 +275,8 @@ void BLO_main_expander(void (*expand_doit_func)(void *, struct Main *, void *));
  */
 void BLO_expand_main(void *fdhandle, struct Main *mainvar);
 
-/* Update defaults in startup.blend, without having to save and embed it */
+/* Update defaults in startup.blend & userprefs.blend, without having to save and embed it */
+void BLO_update_defaults_userpref_blend(void);
 void BLO_update_defaults_startup_blend(struct Main *mainvar);
 
 #ifdef __cplusplus
index fdedd3f4edd2aa5f06233e91841fbcc194f6be39..02f9c1fde17cdc8521c76b470a98c33bb3ba8b7e 100644 (file)
@@ -28,6 +28,7 @@
 #include "BLI_utildefines.h"
 #include "BLI_math.h"
 
+#include "DNA_brush_types.h"
 #include "DNA_freestyle_types.h"
 #include "DNA_linestyle_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_userdef_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_material_types.h"
+#include "DNA_object_types.h"
 
+#include "BKE_brush.h"
+#include "BKE_library.h"
 #include "BKE_main.h"
 
 #include "BLO_readfile.h"
 
-/* Update defaults in startup.blend, without having to save and embed the file.
+
+/**
+ * Override values in in-memory startup.blend, avoids resaving for small changes.
+ */
+void BLO_update_defaults_userpref_blend(void)
+{
+       /* defaults from T37518 */
+
+       U.uiflag |= USER_ZBUF_CURSOR;
+       U.uiflag |= USER_QUIT_PROMPT;
+       U.uiflag |= USER_CONTINUOUS_MOUSE;
+
+       U.versions = 1;
+       U.savetime = 2;
+}
+
+/**
+ * Update defaults in startup.blend, without having to save and embed the file.
  * This function can be emptied each time the startup.blend is updated. */
-void BLO_update_defaults_startup_blend(Main *main)
+void BLO_update_defaults_startup_blend(Main *bmain)
 {
        Scene *scene;
        SceneRenderLayer *srl;
@@ -51,7 +72,7 @@ void BLO_update_defaults_startup_blend(Main *main)
        Mesh *me;
        Material *mat;
 
-       for (scene = main->scene.first; scene; scene = scene->id.next) {
+       for (scene = bmain->scene.first; scene; scene = scene->id.next) {
                scene->r.im_format.planes = R_IMF_PLANES_RGBA;
                scene->r.im_format.compress = 15;
 
@@ -59,9 +80,20 @@ void BLO_update_defaults_startup_blend(Main *main)
                        srl->freestyleConfig.sphere_radius = 0.1f;
                        srl->pass_alpha_threshold = 0.5f;
                }
+
+               if (scene->toolsettings) {
+                       ToolSettings *ts = scene->toolsettings;
+
+                       if (ts->sculpt) {
+                               Sculpt *sculpt = ts->sculpt;
+                               sculpt->paint.symmetry_flags |= PAINT_SYMM_X;
+                               sculpt->flags |= SCULPT_DYNTOPO_COLLAPSE;
+                               sculpt->detail_size = 12;
+                       }
+               }
        }
 
-       for (linestyle = main->linestyle.first; linestyle; linestyle = linestyle->id.next) {
+       for (linestyle = bmain->linestyle.first; linestyle; linestyle = linestyle->id.next) {
                linestyle->flag = LS_SAME_OBJECT | LS_NO_SORTING | LS_TEXTURE;
                linestyle->sort_key = LS_SORT_KEY_DISTANCE_FROM_CAMERA;
                linestyle->integration_type = LS_INTEGRATION_MEAN;
@@ -71,7 +103,7 @@ void BLO_update_defaults_startup_blend(Main *main)
        {
                bScreen *screen;
 
-               for (screen = main->screen.first; screen; screen = screen->id.next) {
+               for (screen = bmain->screen.first; screen; screen = screen->id.next) {
                        ScrArea *area;
                        for (area = screen->areabase.first; area; area = area->next) {
                                SpaceLink *space_link;
@@ -85,13 +117,27 @@ void BLO_update_defaults_startup_blend(Main *main)
                }
        }
 
-       for (me = main->mesh.first; me; me = me->id.next) {
+       for (me = bmain->mesh.first; me; me = me->id.next) {
                me->smoothresh = DEG2RADF(180.0f);
+               me->flag &= ~ME_TWOSIDED;
        }
 
-       for (mat = main->mat.first; mat; mat = mat->id.next) {
+       for (mat = bmain->mat.first; mat; mat = mat->id.next) {
                mat->line_col[0] = mat->line_col[1] = mat->line_col[2] = 0.0f;
                mat->line_col[3] = 1.0f;
        }
+
+       {
+               Brush *br;
+               br = BKE_brush_add(bmain, "Fill");
+               br->imagepaint_tool = PAINT_TOOL_FILL;
+               br->ob_mode = OB_MODE_TEXTURE_PAINT;
+
+               br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Mask");
+               if (br) {
+                       br->imagepaint_tool = PAINT_TOOL_MASK;
+                       br->ob_mode |= OB_MODE_TEXTURE_PAINT;
+               }
+       }
 }
 
index c73efa13f29586ae7beb7b87ef5b3f6abc450f64..139e243eda52653eef95d64ca8cdaabce2742579 100644 (file)
@@ -715,7 +715,6 @@ void UI_remove_popup_handlers_all(struct bContext *C, struct ListBase *handlers)
 
 void UI_init(void);
 void UI_init_userdef(void);
-void UI_init_userdef_factory(void);
 void UI_reinit_font(void);
 void UI_exit(void);
 
index dc9dd6183bbdd8b84a9a674903ac9f25c35ae822..ce75b44a851dcc248dd76074e78420ffc4d3a820 100644 (file)
@@ -4429,11 +4429,6 @@ void UI_init_userdef(void)
        uiStyleInit();
 }
 
-void UI_init_userdef_factory(void)
-{
-       init_userdef_factory();
-}
-
 void UI_reinit_font(void)
 {
        uiStyleInit();
index 830bca393c4d7869012303ffb29f03280f22c48d..fa8b6b1ffee072ce006a9e5df39a04097960afdd 100644 (file)
@@ -593,7 +593,6 @@ int ui_id_icon_get(struct bContext *C, struct ID *id, const bool big);
 
 /* resources.c */
 void init_userdef_do_versions(void);
-void init_userdef_factory(void);
 void ui_theme_init_default(void);
 void ui_style_init_default(void);
 void ui_resources_init(void);
index 1f66a4a472592e45e88e80637e9bd0be5b654641..85836f2d97b447a977df7d3b92b95a3e700a8a64 100644 (file)
 
 #include "MEM_guardedalloc.h"
 
-#include "DNA_brush_types.h"
 #include "DNA_curve_types.h"
-#include "DNA_mesh_types.h"  /* init_userdef_factory */
-#include "DNA_object_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
 #include "DNA_userdef_types.h"
 #include "BLI_utildefines.h"
 #include "BLI_math.h"
 
-#include "BKE_brush.h"
 #include "BKE_DerivedMesh.h"
 #include "BKE_global.h"
 #include "BKE_main.h"
 #include "BKE_texture.h"
-#include "BKE_library.h"
-
 
 #include "BIF_gl.h"
 
@@ -2472,55 +2466,3 @@ void init_userdef_do_versions(void)
 // XXX reset_autosave();
 
 }
-
-/**
- * Override values in in-memory startup.blend, avoids resaving for small changes.
- */
-void init_userdef_factory(void)
-{
-       /* defaults from T37518 */
-
-       U.uiflag |= USER_ZBUF_CURSOR;
-       U.uiflag |= USER_QUIT_PROMPT;
-       U.uiflag |= USER_CONTINUOUS_MOUSE;
-
-       U.versions = 1;
-       U.savetime = 2;
-
-       {
-               Mesh *me;
-               for (me = G.main->mesh.first; me; me = me->id.next) {
-                       me->flag &= ~ME_TWOSIDED;
-               }
-       }
-
-       {
-               Brush *br;
-               br = BKE_brush_add(G.main, "Fill");
-               br->imagepaint_tool = PAINT_TOOL_FILL;
-               br->ob_mode = OB_MODE_TEXTURE_PAINT;
-
-               br = (Brush *)BKE_libblock_find_name(ID_BR, "Mask");
-               if (br) {
-                       br->imagepaint_tool = PAINT_TOOL_MASK;
-                       br->ob_mode |= OB_MODE_TEXTURE_PAINT;
-               }
-       }
-
-       {
-               Scene *scene;
-
-               for (scene = G.main->scene.first; scene; scene = scene->id.next) {
-                       if (scene->toolsettings) {
-                               ToolSettings *ts = scene->toolsettings;
-
-                               if (ts->sculpt) {
-                                       Sculpt *sculpt = ts->sculpt;
-                                       sculpt->paint.symmetry_flags |= PAINT_SYMM_X;
-                                       sculpt->flags |= SCULPT_DYNTOPO_COLLAPSE;
-                                       sculpt->detail_size = 12;
-                               }
-                       }
-               }
-       }
-}
index 0bc6442348c6aedcccff9d58afdbb868f94bcf17..3c28d2b93cdfea68ab8777bfc91faf228e02c530 100644 (file)
@@ -278,11 +278,13 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist)
 /* in case UserDef was read, we re-initialize all, and do versioning */
 static void wm_init_userdef(bContext *C, const bool from_memory)
 {
+       Main *bmain = CTX_data_main(C);
+
        /* versioning is here */
        UI_init_userdef();
        
        MEM_CacheLimiter_set_maximum(((size_t)U.memcachelimit) * 1024 * 1024);
-       sound_init(CTX_data_main(C));
+       sound_init(bmain);
 
        /* needed so loading a file from the command line respects user-pref [#26156] */
        BKE_BIT_TEST_SET(G.fileflags, U.flag & USER_FILENOUI, G_FILE_NO_UI);
@@ -295,7 +297,7 @@ static void wm_init_userdef(bContext *C, const bool from_memory)
 
        /* avoid re-saving for every small change to our prefs, allow overrides */
        if (from_memory) {
-               UI_init_userdef_factory();
+               BLO_update_defaults_userpref_blend();
        }
 
        /* update tempdir from user preferences */