Commit: 913938514d682990ea9b0aebf90574bfe96f43a8
Author: Bastien Montagne
Date:   Tue Oct 6 12:19:29 2015 +0200
Branches: free-refcount-ids
https://developer.blender.org/rB913938514d682990ea9b0aebf90574bfe96f43a8

Merge branch 'master' into free-refcount-ids

===================================================================



===================================================================

diff --cc source/blender/blenkernel/BKE_font.h
index 18bc22b,f20c166..0c96107
--- a/source/blender/blenkernel/BKE_font.h
+++ b/source/blender/blenkernel/BKE_font.h
@@@ -78,9 -78,11 +78,11 @@@ bool BKE_vfont_is_builtin(struct VFont 
  void BKE_vfont_builtin_register(void *mem, int size);
  
  void BKE_vfont_free_data(struct VFont *vfont);
 -void BKE_vfont_free(struct VFont *sc); 
 +void BKE_vfont_free(struct VFont *sc, const bool do_id_user);
  struct VFont *BKE_vfont_builtin_get(void);
- struct VFont *BKE_vfont_load(struct Main *bmain, const char *name);
+ struct VFont *BKE_vfont_load(struct Main *bmain, const char *filepath);
+ struct VFont *BKE_vfont_load_exists_ex(struct Main *bmain, const char 
*filepath, bool *r_exists);
+ struct VFont *BKE_vfont_load_exists(struct Main *bmain, const char *filepath);
  
  bool BKE_vfont_to_curve_ex(struct Main *bmain, struct Object *ob, int mode,
                             struct ListBase *r_nubase,
diff --cc source/blender/blenkernel/intern/sound.c
index 180c82f,7e7cc87..53d6d8b
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@@ -99,17 -92,39 +92,48 @@@ bSound *BKE_sound_new_file(struct Main 
        return sound;
  }
  
+ bSound *BKE_sound_new_file_exists_ex(struct Main *bmain, const char 
*filepath, bool *r_exists)
+ {
+       bSound *sound;
+       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 (sound = bmain->sound.first; sound; sound = sound->id.next) {
+               BLI_strncpy(strtest, sound->name, sizeof(sound->name));
+               BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &sound->id));
+ 
+               if (BLI_path_cmp(strtest, str) == 0) {
+                       sound->id.us++;  /* officially should not, it doesn't 
link here! */
+                       if (r_exists)
+                               *r_exists = true;
+                       return sound;
+               }
+       }
+ 
+       if (r_exists)
+               *r_exists = false;
+       return BKE_sound_new_file(bmain, filepath);
+ }
+ 
+ bSound *BKE_sound_new_file_exists(struct Main *bmain, const char *filepath)
+ {
+       return BKE_sound_new_file_exists_ex(bmain, filepath, NULL);
+ }
+ 
 -void BKE_sound_free(bSound *sound)
 +/**
 + * Free (or release) any data used by this sound (does not free the sound 
itself).
 + *
 + * \param sound The sound to free.
 + * \param do_id_user When \a true, ID datablocks used (referenced) by this 
sound are 'released'
 + *                   (their user count is decreased).
 + */
 +void BKE_sound_free(bSound *sound, const bool UNUSED(do_id_user))
  {
 +      /* No animdata here. */
 +
        if (sound->packedfile) {
                freePackedFile(sound->packedfile);
                sound->packedfile = NULL;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to