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:
authorCampbell Barton <ideasman42@gmail.com>2015-10-06 11:40:15 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-10-06 11:44:02 +0300
commit9f15bcb218ef32d5f15e1e13235d2d7fa667e04a (patch)
tree58669c2b15dad9fb28ca08e122f146318f23b768 /source/blender/makesrna/intern/rna_main_api.c
parent65bd2a6e6ae72a64dd2d3822fe79b44736b82264 (diff)
RNA: Add check_existing arg to other load() funcs
Note: movieclip was doing this already by default, now split into 2 functions, matching image behavior.
Diffstat (limited to 'source/blender/makesrna/intern/rna_main_api.c')
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c39
1 files changed, 30 insertions, 9 deletions
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index dc7987c77e6..5a0da0b7651 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -441,12 +441,17 @@ static void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, PointerR
}
}
-static VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepath)
+static VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepath, int check_existing)
{
VFont *font;
-
errno = 0;
- font = BKE_vfont_load(bmain, filepath);
+
+ if (check_existing) {
+ font = BKE_vfont_load_exists(bmain, filepath);
+ }
+ else {
+ font = BKE_vfont_load(bmain, filepath);
+ }
if (!font)
BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath,
@@ -558,9 +563,17 @@ static void rna_Main_speakers_remove(Main *bmain, ReportList *reports, PointerRN
}
}
-static bSound *rna_Main_sounds_load(Main *bmain, const char *name)
+static bSound *rna_Main_sounds_load(Main *bmain, const char *name, int check_existing)
{
- bSound *sound = BKE_sound_new_file(bmain, name);
+ bSound *sound;
+
+ if (check_existing) {
+ sound = BKE_sound_new_file_exists(bmain, name);
+ }
+ else {
+ sound = BKE_sound_new_file(bmain, name);
+ }
+
id_us_min(&sound->id);
return sound;
}
@@ -680,12 +693,18 @@ static void rna_Main_palettes_remove(Main *bmain, ReportList *reports, PointerRN
}
}
-static MovieClip *rna_Main_movieclip_load(Main *bmain, ReportList *reports, const char *filepath)
+static MovieClip *rna_Main_movieclip_load(Main *bmain, ReportList *reports, const char *filepath, int check_existing)
{
MovieClip *clip;
errno = 0;
- clip = BKE_movieclip_file_add(bmain, filepath);
+
+ if (check_existing) {
+ clip = BKE_movieclip_file_add_exists(bmain, filepath);
+ }
+ else {
+ clip = BKE_movieclip_file_add(bmain, filepath);
+ }
if (!clip)
BKE_reportf(reports, RPT_ERROR, "Cannot read '%s': %s", filepath,
@@ -1212,8 +1231,7 @@ 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");
+ RNA_def_boolean(func, "check_existing", false, "", "Using existing data-block if this file is already loaded");
/* return type */
parm = RNA_def_pointer(func, "image", "Image", "", "New image datablock");
RNA_def_function_return(func, parm);
@@ -1358,6 +1376,7 @@ void RNA_def_main_fonts(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Load a new font into the main database");
parm = RNA_def_string_file_path(func, "filepath", "File Path", 0, "", "path of the font to load");
RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_boolean(func, "check_existing", false, "", "Using existing data-block if this file is already loaded");
/* return type */
parm = RNA_def_pointer(func, "vfont", "VectorFont", "", "New font datablock");
RNA_def_function_return(func, parm);
@@ -1621,6 +1640,7 @@ void RNA_def_main_sounds(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Add a new sound to the main database from a file");
parm = RNA_def_string_file_path(func, "filepath", "Path", FILE_MAX, "", "path for the datablock");
RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_boolean(func, "check_existing", false, "", "Using existing data-block if this file is already loaded");
/* return type */
parm = RNA_def_pointer(func, "sound", "Sound", "", "New text datablock");
RNA_def_function_return(func, parm);
@@ -1844,6 +1864,7 @@ void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_ui_description(func, "Add a new movie clip to the main database from a file");
parm = RNA_def_string_file_path(func, "filepath", "Path", FILE_MAX, "", "path for the datablock");
RNA_def_property_flag(parm, PROP_REQUIRED);
+ RNA_def_boolean(func, "check_existing", false, "", "Using existing data-block if this file is already loaded");
/* return type */
parm = RNA_def_pointer(func, "clip", "MovieClip", "", "New movie clip datablock");
RNA_def_function_return(func, parm);