From 16100f8261770e367b0892bb38c778699ed609fe Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 31 May 2018 16:04:04 +0200 Subject: Cleanup: get rid of last G.main usages in BKE library code. --- source/blender/editors/object/object_add.c | 6 +++--- source/blender/editors/object/object_relations.c | 3 ++- source/blender/editors/object/object_select.c | 6 ++++-- source/blender/editors/sculpt_paint/sculpt.c | 6 ++++-- source/blender/editors/space_info/info_ops.c | 2 +- source/blender/editors/space_node/node_add.c | 3 ++- .../blender/editors/space_outliner/outliner_draw.c | 9 +++++---- .../blender/editors/space_outliner/outliner_edit.c | 22 +++++++++++----------- 8 files changed, 32 insertions(+), 25 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 101b5d4920d..5d5d1190775 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -967,6 +967,7 @@ void OBJECT_OT_lamp_add(wmOperatorType *ot) static int group_instance_add_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Group *group; unsigned int layer; float loc[3], rot[3]; @@ -975,7 +976,7 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) char name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "name", name); - group = (Group *)BKE_libblock_find_name(ID_GR, name); + group = (Group *)BKE_libblock_find_name(bmain, ID_GR, name); if (0 == RNA_struct_property_is_set(op->ptr, "location")) { const wmEvent *event = CTX_wm_window(C)->eventstate; @@ -994,7 +995,6 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; if (group) { - Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_add_type(C, OB_EMPTY, group->id.name + 2, loc, rot, false, layer); ob->dup_group = group; @@ -2354,7 +2354,7 @@ static int add_named_exec(bContext *C, wmOperator *op) /* find object, create fake base */ RNA_string_get(op->ptr, "name", name); - ob = (Object *)BKE_libblock_find_name(ID_OB, name); + ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, name); if (ob == NULL) { BKE_report(op->reports, RPT_ERROR, "Object not found"); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index ee78dc83c26..68bcdc59f4e 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -2485,12 +2485,13 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot) static int drop_named_material_invoke(bContext *C, wmOperator *op, const wmEvent *event) { + Main *bmain = CTX_data_main(C); Base *base = ED_view3d_give_base_under_cursor(C, event->mval); Material *ma; char name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "name", name); - ma = (Material *)BKE_libblock_find_name(ID_MA, name); + ma = (Material *)BKE_libblock_find_name(bmain, ID_MA, name); if (base == NULL || ma == NULL) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 8d5c2387fe9..440c9d01487 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -1076,6 +1076,7 @@ void OBJECT_OT_select_all(wmOperatorType *ot) static int object_select_same_group_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Group *group; char group_name[MAX_ID_NAME]; @@ -1084,7 +1085,7 @@ static int object_select_same_group_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "group", group_name); - group = (Group *)BKE_libblock_find_name(ID_GR, group_name); + group = (Group *)BKE_libblock_find_name(bmain, ID_GR, group_name); if (!group) { return OPERATOR_PASS_THROUGH; @@ -1123,6 +1124,7 @@ void OBJECT_OT_select_same_group(wmOperatorType *ot) /**************************** Select Mirror ****************************/ static int object_select_mirror_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); bool extend; @@ -1135,7 +1137,7 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op) BLI_string_flip_side_name(name_flip, primbase->object->id.name + 2, true, sizeof(name_flip)); if (!STREQ(name_flip, primbase->object->id.name + 2)) { - Object *ob = (Object *)BKE_libblock_find_name(ID_OB, name_flip); + Object *ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, name_flip); if (ob) { Base *secbase = BKE_scene_base_find(scene, ob); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index f9bfe4be866..605d72e1e20 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4200,6 +4200,7 @@ static void sculpt_update_cache_invariants( wmOperator *op, const float mouse[2]) { StrokeCache *cache = MEM_callocN(sizeof(StrokeCache), "stroke cache"); + Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); UnifiedPaintSettings *ups = &CTX_data_tool_settings(C)->unified_paint_settings; Brush *brush = BKE_paint_brush(&sd->paint); @@ -4271,7 +4272,7 @@ static void sculpt_update_cache_invariants( BLI_strncpy(cache->saved_active_brush_name, brush->id.name + 2, sizeof(cache->saved_active_brush_name)); - br = (Brush *)BKE_libblock_find_name(ID_BR, "Smooth"); + br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Smooth"); if (br) { BKE_paint_brush_set(p, br); brush = br; @@ -5006,6 +5007,7 @@ static void sculpt_brush_exit_tex(Sculpt *sd) static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(stroke)) { + Main *bmain = CTX_data_main(C); Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); SculptSession *ss = ob->sculpt; @@ -5027,7 +5029,7 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str } else { BKE_brush_size_set(scene, brush, ss->cache->saved_smooth_size); - brush = (Brush *)BKE_libblock_find_name(ID_BR, ss->cache->saved_active_brush_name); + brush = (Brush *)BKE_libblock_find_name(bmain, ID_BR, ss->cache->saved_active_brush_name); if (brush) { BKE_paint_brush_set(&sd->paint, brush); } diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index b87a0de23b9..1cd3fef979b 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -301,7 +301,7 @@ static int unpack_item_exec(bContext *C, wmOperator *op) int method = RNA_enum_get(op->ptr, "method"); RNA_string_get(op->ptr, "id_name", idname); - id = BKE_libblock_find_name(type, idname); + id = BKE_libblock_find_name(bmain, type, idname); if (id == NULL) { BKE_report(op->reports, RPT_WARNING, "No packed file"); diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index ec35727d176..2dcc69122dd 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -410,6 +410,7 @@ static int node_add_mask_poll(bContext *C) static int node_add_mask_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); SpaceNode *snode = CTX_wm_space_node(C); bNode *node; ID *mask = NULL; @@ -417,7 +418,7 @@ static int node_add_mask_exec(bContext *C, wmOperator *op) /* check input variables */ char name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "name", name); - mask = BKE_libblock_find_name(ID_MSK, name); + mask = BKE_libblock_find_name(bmain, ID_MSK, name); if (!mask) { BKE_reportf(op->reports, RPT_ERROR, "Mask '%s' not found", name); return OPERATOR_CANCELLED; diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index d8d6b09ac6b..2fb7d921d23 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -464,6 +464,7 @@ static void restrictbutton_id_user_toggle(bContext *UNUSED(C), void *poin, void static void namebutton_cb(bContext *C, void *tsep, char *oldname) { + Main *bmain = CTX_data_main(C); SpaceOops *soops = CTX_wm_space_outliner(C); Scene *scene = CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); @@ -474,7 +475,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) TreeElement *te = outliner_find_tree_element(&soops->tree, tselem); if (tselem->type == 0) { - BLI_libblock_ensure_unique_name(G.main, tselem->id->name); + BLI_libblock_ensure_unique_name(bmain, tselem->id->name); switch (GS(tselem->id->name)) { case ID_MA: @@ -493,10 +494,10 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) Library *lib = (Library *)tselem->id; char expanded[FILE_MAX]; - BKE_library_filepath_set(lib, lib->name); + BKE_library_filepath_set(bmain, lib, lib->name); BLI_strncpy(expanded, lib->name, sizeof(expanded)); - BLI_path_abs(expanded, G.main->name); + BLI_path_abs(expanded, bmain->name); if (!BLI_exists(expanded)) { BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "Library path '%s' does not exist, correct this before saving", expanded); @@ -514,7 +515,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) defgroup_unique_name(te->directdata, (Object *)tselem->id); // id = object break; case TSE_NLA_ACTION: - BLI_libblock_ensure_unique_name(G.main, tselem->id->name); + BLI_libblock_ensure_unique_name(bmain, tselem->id->name); break; case TSE_EBONE: { diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 8a9f9f6aff7..27c14096e1e 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1992,9 +1992,9 @@ static int parent_drop_exec(bContext *C, wmOperator *op) partype = RNA_enum_get(op->ptr, "type"); RNA_string_get(op->ptr, "parent", parname); - par = (Object *)BKE_libblock_find_name(ID_OB, parname); + par = (Object *)BKE_libblock_find_name(bmain, ID_OB, parname); RNA_string_get(op->ptr, "child", childname); - ob = (Object *)BKE_libblock_find_name(ID_OB, childname); + ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, childname); if (ID_IS_LINKED(ob)) { BKE_report(op->reports, RPT_INFO, "Can't edit library linked object"); @@ -2033,9 +2033,9 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event) RNA_string_set(op->ptr, "parent", te->name); /* Identify parent and child */ RNA_string_get(op->ptr, "child", childname); - ob = (Object *)BKE_libblock_find_name(ID_OB, childname); + ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, childname); RNA_string_get(op->ptr, "parent", parname); - par = (Object *)BKE_libblock_find_name(ID_OB, parname); + par = (Object *)BKE_libblock_find_name(bmain, ID_OB, parname); if (ELEM(NULL, ob, par)) { if (par == NULL) printf("par==NULL\n"); @@ -2183,7 +2183,7 @@ static int parent_clear_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE char obname[MAX_ID_NAME]; RNA_string_get(op->ptr, "dragged_obj", obname); - ob = (Object *)BKE_libblock_find_name(ID_OB, obname); + ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, obname); /* search forwards to find the object */ outliner_find_id(soops, &soops->tree, (ID *)ob); @@ -2236,10 +2236,10 @@ static int scene_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event) Base *base; RNA_string_set(op->ptr, "scene", te->name); - scene = (Scene *)BKE_libblock_find_name(ID_SCE, te->name); + scene = (Scene *)BKE_libblock_find_name(bmain, ID_SCE, te->name); RNA_string_get(op->ptr, "object", obname); - ob = (Object *)BKE_libblock_find_name(ID_OB, obname); + ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, obname); if (ELEM(NULL, ob, scene) || ID_IS_LINKED(scene)) { return OPERATOR_CANCELLED; @@ -2305,10 +2305,10 @@ static int material_drop_invoke(bContext *C, wmOperator *op, const wmEvent *even if (te) { RNA_string_set(op->ptr, "object", te->name); - ob = (Object *)BKE_libblock_find_name(ID_OB, te->name); + ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, te->name); RNA_string_get(op->ptr, "material", mat_name); - ma = (Material *)BKE_libblock_find_name(ID_MA, mat_name); + ma = (Material *)BKE_libblock_find_name(bmain, ID_MA, mat_name); if (ELEM(NULL, ob, ma)) { return OPERATOR_CANCELLED; @@ -2363,10 +2363,10 @@ static int group_link_invoke(bContext *C, wmOperator *op, const wmEvent *event) te = outliner_dropzone_find(soops, fmval, true); if (te) { - group = (Group *)BKE_libblock_find_name(ID_GR, te->name); + group = (Group *)BKE_libblock_find_name(bmain, ID_GR, te->name); RNA_string_get(op->ptr, "object", ob_name); - ob = (Object *)BKE_libblock_find_name(ID_OB, ob_name); + ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, ob_name); if (ELEM(NULL, group, ob)) { return OPERATOR_CANCELLED; -- cgit v1.2.3