changeset 516:b926f08909b8 alignment-simple

Fix crashes in play() and stop() if no record target / play source present
author Chris Cannam
date Thu, 03 Mar 2016 09:12:28 +0000
parents 51befd6165a3
children c3648c667a0b
files framework/MainWindowBase.cpp
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Wed Mar 02 17:25:27 2016 +0000
+++ b/framework/MainWindowBase.cpp	Thu Mar 03 09:12:28 2016 +0000
@@ -2706,7 +2706,8 @@
 void
 MainWindowBase::play()
 {
-    if (m_recordTarget->isRecording() || m_playSource->isPlaying()) {
+    if ((m_recordTarget && m_recordTarget->isRecording()) ||
+        (m_playSource && m_playSource->isPlaying())) {
         stop();
         QAction *action = qobject_cast<QAction *>(sender());
         if (action) action->setChecked(false);
@@ -3085,10 +3086,13 @@
 void
 MainWindowBase::stop()
 {
-    if (m_recordTarget->isRecording()) {
+    if (m_recordTarget &&
+        m_recordTarget->isRecording()) {
         m_recordTarget->stopRecording();
     }
-        
+
+    if (!m_playSource) return;
+    
     m_playSource->stop();
 
     if (m_audioIO) m_audioIO->suspend();