Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2015-10-05 19:49:20 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-10-05 19:49:20 +0300
commit1cdf82d7f8dd117441405b99f744e2f7095e5c7c (patch)
tree520f3a938ae8aeafc37be7a0ce13527759a6a858 /source/blender
parente5552f82415708778fefd11c0c57cd52213e823e (diff)
Image Py API: Expose 'load_exists' to RNA image load(), and extend load_image() helper.
Expose our `BKE_image_load_exists` feature through an optional parameter to `Image.load()`. Extend `image_utils.load_image()` with two optional parameters, to return existing image datablock if possible, and in that case, to force reloading said image. Needed by incomming 'import images as planes' addon enhancement.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index b38f4fa67b6..dc7987c77e6 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -352,12 +352,17 @@ static Image *rna_Main_images_new(Main *bmain, const char *name, int width, int
id_us_min(&image->id);
return image;
}
-static Image *rna_Main_images_load(Main *bmain, ReportList *reports, const char *filepath)
+static Image *rna_Main_images_load(Main *bmain, ReportList *reports, const char *filepath, int check_existing)
{
Image *ima;
errno = 0;
- ima = BKE_image_load(bmain, filepath);
+ if (check_existing) {
+ ima = BKE_image_load_exists(filepath);
+ }
+ else {
+ ima = BKE_image_load(bmain, filepath);
+ }
if (!ima) {
BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath,
@@ -1207,6 +1212,8 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Load a new image into the main database");
parm = RNA_def_string_file_path(func, "filepath", "File Path", 0, "", "path of the file to load");
RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_boolean(func, "check_existing", false, "",
+ "Check whether this image filepath is already used, and return existing datablock in this case");
/* return type */
parm = RNA_def_pointer(func, "image", "Image", "", "New image datablock");
RNA_def_function_return(func, parm);