diff framework/MainWindowBase.cpp @ 540:0d5c3abc9658 3.0-integration

Delete audio I/O objects in a fixed order
author Chris Cannam
date Wed, 30 Nov 2016 11:44:40 +0000
parents 287fce13a1ae
children baa11365ebdd
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Fri Nov 25 10:08:52 2016 +0000
+++ b/framework/MainWindowBase.cpp	Wed Nov 30 11:44:40 2016 +0000
@@ -287,10 +287,25 @@
 MainWindowBase::~MainWindowBase()
 {
     SVDEBUG << "MainWindowBase::~MainWindowBase" << endl;
+
+    // We have to delete the breakfastquay::SystemPlaybackTarget or
+    // breakfastquay::SystemAudioIO object (whichever we have -- it
+    // depends on whether we handle recording or not) before we delete
+    // the ApplicationPlaybackSource and ApplicationRecordTarget that
+    // they refer to.
+    
+    // First prevent this trying to call target.
+    if (m_playSource) m_playSource->setSystemPlaybackTarget(0);
+
+    // Then delete the breakfastquay::System object.
+    // Only one of these two exists!
+    delete m_audioIO;
     delete m_playTarget;
+
+    // Then delete the Application objects.
     delete m_playSource;
-    delete m_audioIO;
     delete m_recordTarget;
+    
     delete m_viewManager;
     delete m_oscQueue;
     delete m_oscQueueStarter;