Fix T65613: Memory leak in Audaspace with 3D sound
authorJörg Müller <nexyon@gmail.com>
Fri, 7 Jun 2019 20:29:52 +0000 (22:29 +0200)
committerJörg Müller <nexyon@gmail.com>
Fri, 7 Jun 2019 20:30:21 +0000 (22:30 +0200)
source/blender/blenkernel/intern/sound.c

index aba5a0e..029fea5 100644 (file)
@@ -524,12 +524,18 @@ void BKE_sound_destroy_scene(Scene *scene)
   if (scene->sound_scrub_handle) {
     AUD_Handle_stop(scene->sound_scrub_handle);
   }
-  if (scene->sound_scene) {
-    AUD_Sequence_free(scene->sound_scene);
-  }
   if (scene->speaker_handles) {
+    void *handle;
+
+    while ((handle = AUD_getSet(scene->speaker_handles))) {
+      AUD_Sequence_remove(scene->sound_scene, handle);
+    }
+
     AUD_destroySet(scene->speaker_handles);
   }
+  if (scene->sound_scene) {
+    AUD_Sequence_free(scene->sound_scene);
+  }
 }
 
 void BKE_sound_reset_scene_specs(Scene *scene)