diff src/Analyser.cpp @ 252:f99fae5fe89c

Fix accidental nesting of compound commands which broke "Abandon Selection" logic; move note-snap after editing into the compound command for the edit function instead of issuing a separate command
author Chris Cannam
date Wed, 02 Apr 2014 09:12:18 +0100
parents bb32b9fbacf8
children 46d59edfd18a
line wrap: on
line diff
--- a/src/Analyser.cpp	Wed Apr 02 09:03:42 2014 +0100
+++ b/src/Analyser.cpp	Wed Apr 02 09:12:18 2014 +0100
@@ -283,7 +283,12 @@
 {
     if (sel == m_reAnalysingSelection || sel.isEmpty()) return "";
 
-    discardPitchCandidates();
+    if (!m_reAnalysisCandidates.empty()) {
+        CommandHistory::getInstance()->startCompoundOperation
+            (tr("Discard Previous Candidates"), true);
+        discardPitchCandidates();
+        CommandHistory::getInstance()->endCompoundOperation();
+    }
 
     m_reAnalysingSelection = sel;
 
@@ -529,6 +534,8 @@
 void
 Analyser::abandonReAnalysis(Selection sel)
 {
+    // A compound command is already in progress
+
     discardPitchCandidates();
 
     Layer *myLayer = m_layers[PitchTrack];
@@ -541,18 +548,14 @@
 Analyser::discardPitchCandidates()
 {
     if (!m_reAnalysisCandidates.empty()) {
-
-        CommandHistory::getInstance()->startCompoundOperation
-            (tr("Discard Previous Candidates"), true);
-
+        // We don't use a compound command here, because we may be
+        // already in one. Caller bears responsibility for doing that
         foreach (Layer *layer, m_reAnalysisCandidates) {
             // This will cause the layer to be deleted later (ownership is
             // transferred to the remove command)
             m_document->removeLayerFromView(m_pane, layer);
         }
-
         m_reAnalysisCandidates.clear();
-        CommandHistory::getInstance()->endCompoundOperation();
     }
 
     m_currentCandidate = -1;