diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-11-24 00:48:48 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-11-24 00:48:48 +0300 |
commit | 929dbc66445ba2004be52bd29f5bd06bcd1f8a26 (patch) | |
tree | 8631422ffb9b089abbbdae5bc187df6d5b71dae7 /source/blender/editors/space_node/node_add.c | |
parent | 888ab78edfad4f9c2bdd31764eb95eb347a8c2d8 (diff) |
Cleanup: de-duplicate image drag & drop logic
also don't make library paths relative on image load.
Diffstat (limited to 'source/blender/editors/space_node/node_add.c')
-rw-r--r-- | source/blender/editors/space_node/node_add.c | 41 |
1 files changed, 4 insertions, 37 deletions
diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index a22ccac5ecb..1e7fffa44f7 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -29,8 +29,6 @@ * \ingroup spnode */ -#include <errno.h> - #include "MEM_guardedalloc.h" #include "DNA_node_types.h" @@ -305,43 +303,12 @@ static int node_add_file_exec(bContext *C, wmOperator *op) { SpaceNode *snode = CTX_wm_space_node(C); bNode *node; - Image *ima = NULL; + Image *ima; int type = 0; - bool exists = false; - - const bool is_relative_path = RNA_boolean_get(op->ptr, "relative_path"); - - /* check input variables */ - if (RNA_struct_property_is_set(op->ptr, "filepath")) { - char path[FILE_MAX]; - RNA_string_get(op->ptr, "filepath", path); - - errno = 0; - - ima = BKE_image_load_exists_ex(path, &exists); - - if (!ima) { - BKE_reportf(op->reports, RPT_ERROR, "Cannot read image '%s': %s", - path, errno ? strerror(errno) : TIP_("unsupported format")); - return OPERATOR_CANCELLED; - } - - if (is_relative_path) { - 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")) { - char name[MAX_ID_NAME - 2]; - RNA_string_get(op->ptr, "name", name); - ima = (Image *)BKE_libblock_find_name(ID_IM, name); - if (!ima) { - BKE_reportf(op->reports, RPT_ERROR, "Image '%s' not found", name); - return OPERATOR_CANCELLED; - } + ima = (Image *)WM_operator_drop_load_path(C, op, ID_IM); + if (!ima) { + return OPERATOR_CANCELLED; } switch (snode->nodetree->type) { |