diff framework/MainWindowBase.cpp @ 500:dcd2afbc1bb7 3.0-integration

Merge, but dropping the last commit from the recording branch because I prefer the way it was done here
author Chris Cannam
date Wed, 14 Oct 2015 10:17:32 +0100
parents a4d90cf2bb79 40e7b4e1b569
children c82cae9a9e74
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Mon Oct 12 12:43:06 2015 +0100
+++ b/framework/MainWindowBase.cpp	Wed Oct 14 10:17:32 2015 +0100
@@ -2681,28 +2681,39 @@
     if (!m_audioIO) {
         createAudioIO();
     }
+
+    if (!m_audioIO) {
+        //!!! report
+        return;
+    }
     
     if (m_recordTarget->isRecording()) {
-        m_recordTarget->stopRecording();
-        emit audioFileLoaded();
+        stop();
         return;
     }
 
+    QAction *action = qobject_cast<QAction *>(sender());
+    
     if (m_audioRecordMode == RecordReplaceSession) {
-        if (!checkSaveModified()) return;
+        if (!checkSaveModified()) {
+            if (action) action->setChecked(false);
+            return;
+        }
     }
 
+    m_audioIO->resume();
     WritableWaveFileModel *model = m_recordTarget->startRecording();
     if (!model) {
         cerr << "ERROR: MainWindowBase::record: Recording failed" << endl;
         //!!! report
+        if (action) action->setChecked(false);
         return;
     }
 
     if (!model->isOK()) {
         m_recordTarget->stopRecording();
+        m_audioIO->suspend();
         delete model;
-        //!!! ???
         return;
     }
     
@@ -2718,6 +2729,9 @@
         if (templateName != "") {
             FileOpenStatus tplStatus = openSessionTemplate(templateName);
             if (tplStatus == FileOpenCancelled) {
+                m_recordTarget->stopRecording();
+                m_audioIO->suspend();
+                PlayParameterRepository::getInstance()->removePlayable(model);
                 return;
             }
             if (tplStatus != FileOpenFailed) {