diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/space_node/node_add.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 11 |
2 files changed, 13 insertions, 8 deletions
diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index 33eb24ae92a..a22ccac5ecb 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -307,6 +307,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) bNode *node; Image *ima = NULL; int type = 0; + bool exists = false; const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path"); @@ -317,7 +318,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) errno = 0; - ima = BKE_image_load_exists(path); + ima = BKE_image_load_exists_ex(path, &exists); if (!ima) { BKE_reportf(op->reports, RPT_ERROR, "Cannot read image '%s': %s", @@ -326,9 +327,10 @@ static int node_add_file_exec(bContext *C, wmOperator *op) } if (is_relative_path) { - Main *bmain = CTX_data_main(C); - const char *relbase = ID_BLEND_PATH(bmain, &ima->id); - BLI_path_rel(ima->name, relbase); + if (exists == false) { + Main *bmain = CTX_data_main(C); + BLI_path_rel(ima->name, bmain->name); + } } } else if (RNA_struct_property_is_set(op->ptr, "name")) { diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 1eed56a750b..4e997d0eec3 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -4283,6 +4283,7 @@ static int background_image_add_invoke(bContext *C, wmOperator *op, const wmEven Image *ima = NULL; BGpic *bgpic; char name[MAX_ID_NAME - 2]; + bool exists = false; const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path"); @@ -4291,20 +4292,22 @@ static int background_image_add_invoke(bContext *C, wmOperator *op, const wmEven char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); - ima = BKE_image_load_exists(path); + ima = BKE_image_load_exists_ex(path, &exists); } else if (RNA_struct_property_is_set(op->ptr, "name")) { RNA_string_get(op->ptr, "name", name); ima = (Image *)BKE_libblock_find_name(ID_IM, name); + exists = true; } bgpic = background_image_add(C); if (ima) { if (is_relative_path) { - Main *bmain = CTX_data_main(C); - const char *relbase = ID_BLEND_PATH(bmain, &ima->id); - BLI_path_rel(ima->name, relbase); + if (exists == false) { + Main *bmain = CTX_data_main(C); + BLI_path_rel(ima->name, bmain->name); + } } bgpic->ima = ima; |