[Bf-blender-cvs] [f88593d] master: Fix for mixup in startup.blend data init when userprefs.blend was missing

Campbell Barton noreply at git.blender.org
Wed Jul 23 12:24:04 CEST 2014


Commit: f88593df6911f99d576a5b223eb84749e4fce965
Author: Campbell Barton
Date:   Wed Jul 23 20:20:59 2014 +1000
Branches: master
https://developer.blender.org/rBf88593df6911f99d576a5b223eb84749e4fce965

Fix for mixup in startup.blend data init when userprefs.blend was missing

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.

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

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

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

diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 0c7af12..1d37f9e 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -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 *) );
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 8e07564..515287d 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -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)
 {
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index 4fb983c..4b7b9ce 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -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
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index fdedd3f..02f9c1f 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -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"
@@ -36,14 +37,34 @@
 #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;
+		}
+	}
 }
 
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index c73efa1..139e243 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -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);
 
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index dc9dd61..ce75b44 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -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();
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 830bca3..fa8b6b1 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -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);
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 1f66a4a..85836f2 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -35,10 +35,7 @@
 
 #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"
@@ -48,13 +45,10 @@
 #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;
-				}
-			}
-		}
-	}
-}
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 0bc6442..3c28d2b 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -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

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list