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/blenkernel/intern/movieclip.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/blenkernel/intern/movieclip.c')
-rw-r--r--source/blender/blenkernel/intern/movieclip.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 7a8c4ad4564..ed92c942b57 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -605,7 +605,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name)
MovieClip *clip;
int file, len;
const char *libname;
- char str[FILE_MAX], strtest[FILE_MAX];
+ char str[FILE_MAX];
BLI_strncpy(str, name, sizeof(str));
BLI_path_abs(str, bmain->name);
@@ -616,19 +616,6 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name)
return NULL;
close(file);
- /* ** first search an identical clip ** */
- for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
- BLI_strncpy(strtest, clip->name, sizeof(clip->name));
- BLI_path_abs(strtest, G.main->name);
-
- if (STREQ(strtest, str)) {
- BLI_strncpy(clip->name, name, sizeof(clip->name)); /* for stringcode */
- clip->id.us++; /* officially should not, it doesn't link here! */
-
- return clip;
- }
- }
-
/* ** add new movieclip ** */
/* create a short library name */
@@ -655,6 +642,37 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *name)
return clip;
}
+MovieClip *BKE_movieclip_file_add_exists_ex(Main *bmain, const char *filepath, bool *r_exists)
+{
+ MovieClip *clip;
+ char str[FILE_MAX], strtest[FILE_MAX];
+
+ BLI_strncpy(str, filepath, sizeof(str));
+ BLI_path_abs(str, bmain->name);
+
+ /* first search an identical filepath */
+ for (clip = bmain->movieclip.first; clip; clip = clip->id.next) {
+ BLI_strncpy(strtest, clip->name, sizeof(clip->name));
+ BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &clip->id));
+
+ if (BLI_path_cmp(strtest, str) == 0) {
+ clip->id.us++; /* officially should not, it doesn't link here! */
+ if (r_exists)
+ *r_exists = true;
+ return clip;
+ }
+ }
+
+ if (r_exists)
+ *r_exists = false;
+ return BKE_movieclip_file_add(bmain, filepath);
+}
+
+MovieClip *BKE_movieclip_file_add_exists(Main *bmain, const char *filepath)
+{
+ return BKE_movieclip_file_add_exists_ex(bmain, filepath, NULL);
+}
+
static void real_ibuf_size(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, int *width, int *height)
{
*width = ibuf->x;