When Sound blocks are loaded, they can have packedfiles. If a Sound isn't
authorTon Roosendaal <ton@blender.org>
Fri, 23 Apr 2004 13:11:29 +0000 (13:11 +0000)
committerTon Roosendaal <ton@blender.org>
Fri, 23 Apr 2004 13:11:29 +0000 (13:11 +0000)
played (= packedfiles opened and copied to another block) these
packed data blocks where not freed.

The error showed in console at closing of Blender, like:
read_struct len: 24 0x1c4423c

source/blender/blenkernel/intern/sound.c

index e4449ad0139af400d79b48586a9750fdbc103f73..3c1260c23ebb8bc51cf7eaa7ca317a1d3b07bcb9 100644 (file)
@@ -28,11 +28,14 @@ ListBase _samples = {0,0}, *samples = &_samples;
 
 void sound_free_sound(bSound *sound)
 {
-       /* this crashes blender, PLEASE fix! */
-       // still crashes :(
-       //if (sound) {
-       //      sound_set_sample(sound, NULL);
-       //}
+       /* when sounds have been loaded, but not played, the packedfile was not copied
+          to sample block and not freed otherwise */
+       if(sound->sample==NULL) {
+               if (sound->newpackedfile) {
+                       freePackedFile(sound->newpackedfile); 
+                       sound->newpackedfile = NULL;
+               }
+       }
        if (sound->stream) MEM_freeN(sound->stream);
 }