[Bf-blender-cvs] [f3fe1f9] master: Refactor: pass Main to id_make_local.

Bastien Montagne noreply at git.blender.org
Fri Jul 8 18:20:04 CEST 2016


Commit: f3fe1f9c44b08de6d18cad27d8751585568b7e8e
Author: Bastien Montagne
Date:   Fri Jul 8 16:14:55 2016 +0200
Branches: master
https://developer.blender.org/rBf3fe1f9c44b08de6d18cad27d8751585568b7e8e

Refactor: pass Main to id_make_local.

Totally stupid to not pass it, and then let (some) BKE_foo_make_local() use G.main!

Note: unused for now, much more refactoring still to come in make_local area!

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

M	source/blender/blenkernel/BKE_library.h
M	source/blender/blenkernel/intern/library.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/editors/object/object_relations.c
M	source/blender/editors/space_outliner/outliner_tools.c

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

diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h
index 56f040a..37937aa 100644
--- a/source/blender/blenkernel/BKE_library.h
+++ b/source/blender/blenkernel/BKE_library.h
@@ -81,7 +81,7 @@ void id_us_min(struct ID *id);
 void id_fake_user_set(struct ID *id);
 void id_fake_user_clear(struct ID *id);
 
-bool id_make_local(struct ID *id, bool test);
+bool id_make_local(struct Main *bmain, struct ID *id, bool test);
 bool id_single_user(struct bContext *C, struct ID *id, struct PointerRNA *ptr, struct PropertyRNA *prop);
 bool id_copy(struct ID *id, struct ID **newid, bool test);
 void id_sort_by_name(struct ListBase *lb, struct ID *id);
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 553dd17..374afa6 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -253,7 +253,7 @@ void id_fake_user_clear(ID *id)
 
 /* calls the appropriate make_local method for the block, unless test. Returns true
  * if the block can be made local. */
-bool id_make_local(ID *id, bool test)
+bool id_make_local(Main *UNUSED(bmain), ID *id, bool test)
 {
 	if (id->tag & LIB_TAG_INDIRECT)
 		return false;
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index 7205cdb..77dc822 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -302,7 +302,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event)
 			break;
 		case UI_ID_LOCAL:
 			if (id) {
-				if (id_make_local(id, false)) {
+				if (id_make_local(CTX_data_main(C), id, false)) {
 					/* reassign to get get proper updates/notifiers */
 					idptr = RNA_property_pointer_get(&template->ptr, template->prop);
 					RNA_property_pointer_set(&template->ptr, template->prop, idptr);
@@ -455,7 +455,7 @@ static void template_ID(
 			else {
 				but = uiDefIconBut(block, UI_BTYPE_BUT, 0, ICON_LIBRARY_DATA_DIRECT, 0, 0, UI_UNIT_X, UI_UNIT_Y,
 				                   NULL, 0, 0, 0, 0, TIP_("Direct linked library datablock, click to make local"));
-				if (!id_make_local(id, true /* test */) || (idfrom && idfrom->lib))
+				if (!id_make_local(CTX_data_main(C), id, true /* test */) || (idfrom && idfrom->lib))
 					UI_but_flag_enable(but, UI_BUT_DISABLED);
 			}
 
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index af1c840..255477b 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -2104,11 +2104,11 @@ static void make_local_makelocalmaterial(Material *ma)
 	AnimData *adt;
 	int b;
 
-	id_make_local(&ma->id, false);
+	id_make_local(G.main, &ma->id, false);
 
 	for (b = 0; b < MAX_MTEX; b++)
 		if (ma->mtex[b] && ma->mtex[b]->tex)
-			id_make_local(&ma->mtex[b]->tex->id, false);
+			id_make_local(G.main, &ma->mtex[b]->tex->id, false);
 
 	adt = BKE_animdata_from_id(&ma->id);
 	if (adt) BKE_animdata_make_local(adt);
@@ -2237,7 +2237,7 @@ static int make_local_exec(bContext *C, wmOperator *op)
 		}
 
 		if (ob->id.lib)
-			id_make_local(&ob->id, false);
+			id_make_local(bmain, &ob->id, false);
 	}
 	CTX_DATA_END;
 
@@ -2259,7 +2259,7 @@ static int make_local_exec(bContext *C, wmOperator *op)
 		id = ob->data;
 
 		if (id && (ELEM(mode, MAKE_LOCAL_SELECT_OBDATA, MAKE_LOCAL_SELECT_OBDATA_MATERIAL))) {
-			id_make_local(id, false);
+			id_make_local(bmain, id, false);
 			adt = BKE_animdata_from_id(id);
 			if (adt) BKE_animdata_make_local(adt);
 
@@ -2275,7 +2275,7 @@ static int make_local_exec(bContext *C, wmOperator *op)
 		}
 
 		for (psys = ob->particlesystem.first; psys; psys = psys->next)
-			id_make_local(&psys->part->id, false);
+			id_make_local(bmain, &psys->part->id, false);
 
 		adt = BKE_animdata_from_id(&ob->id);
 		if (adt) BKE_animdata_make_local(adt);
@@ -2294,7 +2294,7 @@ static int make_local_exec(bContext *C, wmOperator *op)
 
 				for (b = 0; b < MAX_MTEX; b++)
 					if (la->mtex[b] && la->mtex[b]->tex)
-						id_make_local(&la->mtex[b]->tex->id, false);
+						id_make_local(bmain, &la->mtex[b]->tex->id, false);
 			}
 			else {
 				for (a = 0; a < ob->totcol; a++) {
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 13adaff..f3235d0 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -436,10 +436,10 @@ static void id_local_cb(
         TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data))
 {
 	if (ID_IS_LINKED_DATABLOCK(tselem->id) && (tselem->id->tag & LIB_TAG_EXTERN)) {
+		Main *bmain = CTX_data_main(C);
 		/* if the ID type has no special local function,
 		 * just clear the lib */
-		if (id_make_local(tselem->id, false) == false) {
-			Main *bmain = CTX_data_main(C);
+		if (id_make_local(bmain, tselem->id, false) == false) {
 			id_clear_lib_data(bmain, tselem->id);
 		}
 	}




More information about the Bf-blender-cvs mailing list