changeset 72:081202998535

Regenerate analysis on main-model change, not on explicit user actions to load a file -- so that it works with files loaded from command line as well
author Chris Cannam
date Thu, 28 Nov 2013 15:13:56 +0000
parents fc3b62262443
children 3bab1fc3e877
files src/MainWindow.cpp src/MainWindow.h
diffstat 2 files changed, 13 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/MainWindow.cpp	Thu Nov 28 13:12:03 2013 +0000
+++ b/src/MainWindow.cpp	Thu Nov 28 15:13:56 2013 +0000
@@ -857,8 +857,6 @@
     } else if (status == FileOpenWrongMode) {
         QMessageBox::critical(this, tr("Failed to open file"),
                               tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
-    } else {
-        configureNewPane(m_paneStack->getCurrentPane());
     }
 }
 
@@ -889,8 +887,6 @@
     } else if (status == FileOpenWrongMode) {
         QMessageBox::critical(this, tr("Failed to open location"),
                               tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
-    } else {
-        configureNewPane(m_paneStack->getCurrentPane());
     }
 }
 
@@ -917,8 +913,6 @@
     } else if (status == FileOpenWrongMode) {
         QMessageBox::critical(this, tr("Failed to open location"),
                               tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
-    } else {
-        configureNewPane(m_paneStack->getCurrentPane());
     }
 }
 
@@ -957,8 +951,6 @@
         } else if (status == FileOpenWrongMode) {
             QMessageBox::critical(this, tr("Failed to open dropped URL"),
                                   tr("<b>Audio required</b><p>Please load at least one audio file before importing annotation data"));
-        } else {
-            configureNewPane(m_paneStack->getCurrentPane());
         }
     }
 }
@@ -983,18 +975,6 @@
 }
 
 void
-MainWindow::configureNewPane(Pane *pane)
-{
-    cerr << "MainWindow::configureNewPane(" << pane << ")" << endl;
-
-    if (!pane) {
-        pane = m_paneStack->addPane();
-    }
-
-    m_analyser->newFileLoaded(m_document, getMainModel(), m_paneStack, pane);
-}
-
-void
 MainWindow::closeEvent(QCloseEvent *e)
 {
 //    cerr << "MainWindow::closeEvent" << endl;
@@ -1463,6 +1443,19 @@
         connect(m_fader, SIGNAL(valueChanged(float)),
                 m_playTarget, SLOT(setOutputGain(float)));
     }
+
+    if (model) {
+        if (m_paneStack) {
+            Pane *pane = m_paneStack->getCurrentPane();
+            if (!pane) {
+                pane = m_paneStack->addPane();
+            }
+            if (pane) {
+                m_analyser->newFileLoaded
+                    (m_document, getMainModel(), m_paneStack, pane);
+            }
+        }
+    }
 }
 
 void
--- a/src/MainWindow.h	Thu Nov 28 13:12:03 2013 +0000
+++ b/src/MainWindow.h	Thu Nov 28 15:13:56 2013 +0000
@@ -137,7 +137,6 @@
     virtual void closeEvent(QCloseEvent *e);
     bool checkSaveModified();
 
-    virtual void configureNewPane(Pane *p);
     virtual void updateVisibleRangeDisplay(Pane *p) const;
     virtual void updatePositionStatusDisplays() const;
 };