[Bf-blender-cvs] [da9b1b14ed0] master: Cleanup: some more G.main removal/validation...

Bastien Montagne noreply at git.blender.org
Fri Jun 15 17:21:28 CEST 2018


Commit: da9b1b14ed0ffd29fcff8f4ca64fff5f034532fc
Author: Bastien Montagne
Date:   Fri Jun 15 17:21:07 2018 +0200
Branches: master
https://developer.blender.org/rBda9b1b14ed0ffd29fcff8f4ca64fff5f034532fc

Cleanup: some more G.main removal/validation...

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

M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/editors/gpencil/gpencil_undo.c
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/mesh/editmesh_utils.c
M	source/blender/editors/physics/dynamicpaint_ops.c
M	source/blender/editors/physics/physics_fluid.c
M	source/blender/editors/physics/physics_pointcache.c
M	source/blender/editors/undo/ed_undo.c
M	source/blender/editors/util/ed_util.c

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

diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 9b79415f006..6a59ea4439f 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -805,6 +805,7 @@ bGPdata *BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bool in
 		return gpd_dst;
 	}
 	else {
+		BLI_assert(bmain != NULL);
 		bGPdata *gpd_copy;
 		BKE_id_copy_ex(bmain, &gpd_src->id, (ID **)&gpd_copy, 0, false);
 		return gpd_copy;
diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c
index 5e2be7c41f0..d35df8bc380 100644
--- a/source/blender/editors/gpencil/gpencil_undo.c
+++ b/source/blender/editors/gpencil/gpencil_undo.c
@@ -179,7 +179,7 @@ void gpencil_undo_push(bGPdata *gpd)
 
 	/* create new undo node */
 	undo_node = MEM_callocN(sizeof(bGPundonode), "gpencil undo node");
-	undo_node->gpd = BKE_gpencil_data_duplicate(G.main, gpd, true);
+	undo_node->gpd = BKE_gpencil_data_duplicate(NULL, gpd, true);
 
 	cur_node = undo_node;
 
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index cf3e3d9e599..c9145b7d247 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -1733,7 +1733,8 @@ static void search_id_collection(StructRNA *ptype, PointerRNA *ptr, PropertyRNA
 	StructRNA *srna;
 
 	/* look for collection property in Main */
-	RNA_main_pointer_create(G.main, ptr);
+	/* Note: using global Main is OK-ish here, UI shall not access other Mains anyay... */
+	RNA_main_pointer_create(G_MAIN, ptr);
 
 	*prop = NULL;
 
diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c
index e1303b14f0e..4500aeda70a 100644
--- a/source/blender/editors/mesh/editmesh_utils.c
+++ b/source/blender/editors/mesh/editmesh_utils.c
@@ -358,7 +358,7 @@ void EDBM_mesh_load(Main *bmain, Object *ob)
 	 * cycles.
 	 */
 #if 0
-	for (Object *other_object = G.main->object.first;
+	for (Object *other_object = bmain->object.first;
 	     other_object != NULL;
 	     other_object = other_object->id.next)
 	{
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c
index c04fb8d63d1..480d17bbf85 100644
--- a/source/blender/editors/physics/dynamicpaint_ops.c
+++ b/source/blender/editors/physics/dynamicpaint_ops.c
@@ -313,7 +313,7 @@ static void dpaint_bake_endjob(void *customdata)
 	G.is_rendering = false;
 	BKE_spacedata_draw_locks(false);
 
-	WM_set_locked_interface(G.main->wm.first, false);
+	WM_set_locked_interface(G_MAIN->wm.first, false);
 
 	/* Bake was successful:
 	 *  Report for ended bake and how long it took */
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 4b9ce1ca210..c740fc0667e 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -395,7 +395,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid
 
 		/* XXX: This can't be used due to an anim sys optimization that ignores recalc object animation,
 		 * leaving it for the depgraph (this ignores object animation such as modifier properties though... :/ )
-		 * --> BKE_animsys_evaluate_all_animation(G.main, eval_time);
+		 * --> BKE_animsys_evaluate_all_animation(CTX_data_main(C), eval_time);
 		 * This doesn't work with drivers:
 		 * --> BKE_animsys_evaluate_animdata(&fsDomain->id, fsDomain->adt, eval_time, ADT_RECALC_ALL);
 		 */
diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c
index 53aa14d3a56..5205463b5ab 100644
--- a/source/blender/editors/physics/physics_pointcache.c
+++ b/source/blender/editors/physics/physics_pointcache.c
@@ -139,7 +139,7 @@ static void ptcache_job_endjob(void *customdata)
 	G.is_rendering = false;
 	BKE_spacedata_draw_locks(false);
 
-	WM_set_locked_interface(G.main->wm.first, false);
+	WM_set_locked_interface(G_MAIN->wm.first, false);
 
 	WM_main_add_notifier(NC_SCENE | ND_FRAME, scene);
 	WM_main_add_notifier(NC_OBJECT | ND_POINTCACHE, job->baker->pid.ob);
diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c
index 539d0245306..4472b8f9a09 100644
--- a/source/blender/editors/undo/ed_undo.c
+++ b/source/blender/editors/undo/ed_undo.c
@@ -200,7 +200,7 @@ bool ED_undo_is_valid(const bContext *C, const char *undoname)
  */
 UndoStack *ED_undo_stack_get(void)
 {
-	wmWindowManager *wm = G.main->wm.first;
+	wmWindowManager *wm = G_MAIN->wm.first;
 	return wm->undo_stack;
 }
 
diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c
index b22ab9d5878..67b43814d40 100644
--- a/source/blender/editors/util/ed_util.c
+++ b/source/blender/editors/util/ed_util.c
@@ -133,8 +133,8 @@ void ED_editors_exit(bContext *C)
 		return;
 
 	/* frees all editmode undos */
-	if (G.main->wm.first) {
-		wmWindowManager *wm = G.main->wm.first;
+	if (G_MAIN->wm.first) {
+		wmWindowManager *wm = G_MAIN->wm.first;
 		/* normally we don't check for NULL undo stack, do here since it may run in different context. */
 		if (wm->undo_stack) {
 			BKE_undosys_stack_destroy(wm->undo_stack);



More information about the Bf-blender-cvs mailing list