forked from bartvdbraak/blender
Cleanup: get rid of last G.main usages in BKE library code.
This commit is contained in:
parent
b53d358261
commit
16100f8261
@ -88,8 +88,7 @@ void *BKE_libblock_copy_nolib(const struct ID *id, const bool do_action) ATTR_NO
|
||||
void BKE_libblock_rename(struct Main *bmain, struct ID *id, const char *name) ATTR_NONNULL();
|
||||
void BLI_libblock_ensure_unique_name(struct Main *bmain, const char *name) ATTR_NONNULL();
|
||||
|
||||
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();
|
||||
struct ID *BKE_libblock_find_name(struct Main *bmain, const short type, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||
|
||||
/* library_remap.c (keep here since they're general functions) */
|
||||
/**
|
||||
@ -133,7 +132,7 @@ void BKE_libblock_free_data(struct ID *id, const bool do_id_user) ATTR_NONNULL(
|
||||
|
||||
void BKE_id_lib_local_paths(struct Main *bmain, struct Library *lib, struct ID *id);
|
||||
void id_lib_extern(struct ID *id);
|
||||
void BKE_library_filepath_set(struct Library *lib, const char *filepath);
|
||||
void BKE_library_filepath_set(struct Main *bmain, struct Library *lib, const char *filepath);
|
||||
void id_us_ensure_real(struct ID *id);
|
||||
void id_us_clear_real(struct ID *id);
|
||||
void id_us_plus_no_lib(struct ID *id);
|
||||
|
@ -651,7 +651,7 @@ void BKE_bpath_traverse_id(Main *bmain, ID *id, BPathVisitor visit_cb, const int
|
||||
/* keep packedfile paths always relative to the blend */
|
||||
if (lib->packedfile == NULL) {
|
||||
if (rewrite_path_fixed(lib->name, visit_cb, absbase, bpath_user_data)) {
|
||||
BKE_library_filepath_set(lib, lib->name);
|
||||
BKE_library_filepath_set(bmain, lib, lib->name);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1594,17 +1594,12 @@ void BKE_main_thumbnail_create(struct Main *bmain)
|
||||
}
|
||||
|
||||
/* ***************** ID ************************ */
|
||||
ID *BKE_libblock_find_name_ex(struct Main *bmain, const short type, const char *name)
|
||||
ID *BKE_libblock_find_name(struct Main *bmain, const short type, const char *name)
|
||||
{
|
||||
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)
|
||||
{
|
||||
@ -1934,7 +1929,7 @@ static void library_make_local_copying_check(ID *id, GSet *loop_tags, MainIDRela
|
||||
|
||||
/** Make linked datablocks local.
|
||||
*
|
||||
* \param bmain Almost certainly G.main.
|
||||
* \param bmain Almost certainly global main.
|
||||
* \param lib If not NULL, only make local datablocks from this library.
|
||||
* \param untagged_only If true, only make local datablocks not tagged with LIB_TAG_PRE_EXISTING.
|
||||
* \param set_fake If true, set fake user on all localized datablocks (except group and objects ones).
|
||||
@ -2366,7 +2361,7 @@ void BKE_id_ui_prefix(char name[MAX_ID_NAME + 1], const ID *id)
|
||||
strcpy(name + 3, id->name + 2);
|
||||
}
|
||||
|
||||
void BKE_library_filepath_set(Library *lib, const char *filepath)
|
||||
void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath)
|
||||
{
|
||||
/* in some cases this is used to update the absolute path from the
|
||||
* relative */
|
||||
@ -2385,8 +2380,8 @@ void BKE_library_filepath_set(Library *lib, const char *filepath)
|
||||
* since making local could cause this to be directly linked - campbell
|
||||
*/
|
||||
/* Never make paths relative to parent lib - reading code (blenloader) always set *all* lib->name relative to
|
||||
* current G.main, not to their parent for indirectly linked ones. */
|
||||
const char *basepath = G.main->name;
|
||||
* current main, not to their parent for indirectly linked ones. */
|
||||
const char *basepath = bmain->name;
|
||||
BLI_path_abs(lib->filepath, basepath);
|
||||
}
|
||||
}
|
||||
|
@ -960,7 +960,7 @@ void BKE_scene_set_background(Main *bmain, Scene *scene)
|
||||
/* called from creator_args.c */
|
||||
Scene *BKE_scene_set_name(Main *bmain, const char *name)
|
||||
{
|
||||
Scene *sce = (Scene *)BKE_libblock_find_name_ex(bmain, ID_SCE, name);
|
||||
Scene *sce = (Scene *)BKE_libblock_find_name(bmain, ID_SCE, name);
|
||||
if (sce) {
|
||||
BKE_scene_set_background(bmain, sce);
|
||||
printf("Scene switch for render: '%s' in file: '%s'\n", name, bmain->name);
|
||||
|
@ -81,7 +81,7 @@ bool BLO_main_validate_libraries(struct Main *bmain, struct ReportList *reports)
|
||||
continue;
|
||||
}
|
||||
|
||||
BKE_library_filepath_set(curlib, curlib->name);
|
||||
BKE_library_filepath_set(bmain, curlib, curlib->name);
|
||||
BlendHandle *bh = BLO_blendhandle_from_file(curlib->filepath, reports);
|
||||
|
||||
if (bh == NULL) {
|
||||
|
@ -8205,7 +8205,7 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short
|
||||
}
|
||||
else {
|
||||
DEBUG_PRINTF("... in %s (%s): ", main->curlib ? main->curlib->id.name : "<NULL>", main->curlib ? main->curlib->name : "<NULL>");
|
||||
if ((id = BKE_libblock_find_name_ex(main, GS(idname), idname + 2))) {
|
||||
if ((id = BKE_libblock_find_name(main, GS(idname), idname + 2))) {
|
||||
DEBUG_PRINTF("FOUND!\n");
|
||||
/* Even though we found our linked ID, there is no guarantee its address is still the same... */
|
||||
if (id != bhead->old) {
|
||||
|
@ -230,7 +230,7 @@ void BLO_update_defaults_startup_blend(Main *bmain)
|
||||
{
|
||||
Object *ob;
|
||||
|
||||
ob = (Object *)BKE_libblock_find_name_ex(bmain, ID_OB, "Camera");
|
||||
ob = (Object *)BKE_libblock_find_name(bmain, ID_OB, "Camera");
|
||||
if (ob) {
|
||||
ob->rot[1] = 0.0f;
|
||||
}
|
||||
@ -239,7 +239,7 @@ void BLO_update_defaults_startup_blend(Main *bmain)
|
||||
{
|
||||
Brush *br;
|
||||
|
||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Fill");
|
||||
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Fill");
|
||||
if (!br) {
|
||||
br = BKE_brush_add(bmain, "Fill", OB_MODE_TEXTURE_PAINT);
|
||||
id_us_min(&br->id); /* fake user only */
|
||||
@ -248,14 +248,14 @@ void BLO_update_defaults_startup_blend(Main *bmain)
|
||||
}
|
||||
|
||||
/* Vertex/Weight Paint */
|
||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Average");
|
||||
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Average");
|
||||
if (!br) {
|
||||
br = BKE_brush_add(bmain, "Average", OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT);
|
||||
id_us_min(&br->id); /* fake user only */
|
||||
br->vertexpaint_tool = PAINT_BLEND_AVERAGE;
|
||||
br->ob_mode = OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT;
|
||||
}
|
||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Smear");
|
||||
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Smear");
|
||||
if (!br) {
|
||||
br = BKE_brush_add(bmain, "Smear", OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT);
|
||||
id_us_min(&br->id); /* fake user only */
|
||||
@ -263,49 +263,49 @@ void BLO_update_defaults_startup_blend(Main *bmain)
|
||||
br->ob_mode = OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT;
|
||||
}
|
||||
|
||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Mask");
|
||||
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Mask");
|
||||
if (br) {
|
||||
br->imagepaint_tool = PAINT_TOOL_MASK;
|
||||
br->ob_mode |= OB_MODE_TEXTURE_PAINT;
|
||||
}
|
||||
|
||||
/* remove polish brush (flatten/contrast does the same) */
|
||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Polish");
|
||||
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Polish");
|
||||
if (br) {
|
||||
BKE_libblock_delete(bmain, br);
|
||||
}
|
||||
|
||||
/* remove brush brush (huh?) from some modes (draw brushes do the same) */
|
||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Brush");
|
||||
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Brush");
|
||||
if (br) {
|
||||
BKE_libblock_delete(bmain, br);
|
||||
}
|
||||
|
||||
/* remove draw brush from texpaint (draw brushes do the same) */
|
||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Draw");
|
||||
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Draw");
|
||||
if (br) {
|
||||
br->ob_mode &= ~OB_MODE_TEXTURE_PAINT;
|
||||
}
|
||||
|
||||
/* rename twist brush to rotate brush to match rotate tool */
|
||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Twist");
|
||||
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Twist");
|
||||
if (br) {
|
||||
BKE_libblock_rename(bmain, &br->id, "Rotate");
|
||||
}
|
||||
|
||||
/* use original normal for grab brush (otherwise flickers with normal weighting). */
|
||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Grab");
|
||||
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Grab");
|
||||
if (br) {
|
||||
br->flag |= BRUSH_ORIGINAL_NORMAL;
|
||||
}
|
||||
|
||||
/* increase strength, better for smoothing method */
|
||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Blur");
|
||||
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Blur");
|
||||
if (br) {
|
||||
br->alpha = 1.0f;
|
||||
}
|
||||
|
||||
br = (Brush *)BKE_libblock_find_name_ex(bmain, ID_BR, "Flatten/Contrast");
|
||||
br = (Brush *)BKE_libblock_find_name(bmain, ID_BR, "Flatten/Contrast");
|
||||
if (br) {
|
||||
br->flag |= BRUSH_ACCUMULATE;
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -470,7 +470,7 @@ static void rna_IDMaterials_clear_id(ID *id, Main *bmain, int remove_material_sl
|
||||
static void rna_Library_filepath_set(PointerRNA *ptr, const char *value)
|
||||
{
|
||||
Library *lib = (Library *)ptr->data;
|
||||
BKE_library_filepath_set(lib, value);
|
||||
BKE_library_filepath_set(G.main, lib, value);
|
||||
}
|
||||
|
||||
/* ***** ImagePreview ***** */
|
||||
|
@ -539,7 +539,7 @@ static int wm_lib_relocate_invoke(bContext *C, wmOperator *op, const wmEvent *UN
|
||||
char lib_name[MAX_NAME];
|
||||
|
||||
RNA_string_get(op->ptr, "library", lib_name);
|
||||
lib = (Library *)BKE_libblock_find_name_ex(CTX_data_main(C), ID_LI, lib_name);
|
||||
lib = (Library *)BKE_libblock_find_name(CTX_data_main(C), ID_LI, lib_name);
|
||||
|
||||
if (lib) {
|
||||
if (lib->parent) {
|
||||
@ -784,7 +784,7 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload)
|
||||
char lib_name[MAX_NAME];
|
||||
|
||||
RNA_string_get(op->ptr, "library", lib_name);
|
||||
lib = (Library *)BKE_libblock_find_name_ex(CTX_data_main(C), ID_LI, lib_name);
|
||||
lib = (Library *)BKE_libblock_find_name(CTX_data_main(C), ID_LI, lib_name);
|
||||
|
||||
if (lib) {
|
||||
Main *bmain = CTX_data_main(C);
|
||||
|
@ -1306,6 +1306,7 @@ wmOperator *WM_operator_last_redo(const bContext *C)
|
||||
*/
|
||||
ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short idcode)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
ID *id = NULL;
|
||||
/* check input variables */
|
||||
if (RNA_struct_property_is_set(op->ptr, "filepath")) {
|
||||
@ -1333,8 +1334,6 @@ ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short i
|
||||
|
||||
if (is_relative_path ) {
|
||||
if (exists == false) {
|
||||
Main *bmain = CTX_data_main(C);
|
||||
|
||||
if (idcode == ID_IM) {
|
||||
BLI_path_rel(((Image *)id)->name, bmain->name);
|
||||
}
|
||||
@ -1347,7 +1346,7 @@ ID *WM_operator_drop_load_path(struct bContext *C, wmOperator *op, const short i
|
||||
else if (RNA_struct_property_is_set(op->ptr, "name")) {
|
||||
char name[MAX_ID_NAME - 2];
|
||||
RNA_string_get(op->ptr, "name", name);
|
||||
id = BKE_libblock_find_name(idcode, name);
|
||||
id = BKE_libblock_find_name(bmain, idcode, name);
|
||||
if (!id) {
|
||||
BKE_reportf(op->reports, RPT_ERROR, "%s '%s' not found",
|
||||
BKE_idcode_to_name(idcode), name);
|
||||
|
@ -1732,8 +1732,9 @@ static int arg_handle_python_text_run(int argc, const char **argv, void *data)
|
||||
|
||||
/* workaround for scripts not getting a bpy.context.scene, causes internal errors elsewhere */
|
||||
if (argc > 1) {
|
||||
Main *bmain = CTX_data_main(C);
|
||||
/* Make the path absolute because its needed for relative linked blends to be found */
|
||||
struct Text *text = (struct Text *)BKE_libblock_find_name(ID_TXT, argv[1]);
|
||||
struct Text *text = (struct Text *)BKE_libblock_find_name(bmain, ID_TXT, argv[1]);
|
||||
bool ok;
|
||||
|
||||
if (text) {
|
||||
|
Loading…
Reference in New Issue
Block a user