changeset 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 3b5ea600829c
children b6b2f69c516d
files src/Analyser.cpp src/MainWindow.cpp
diffstat 2 files changed, 15 insertions(+), 19 deletions(-) [+]
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;
--- a/src/MainWindow.cpp	Wed Apr 02 09:03:42 2014 +0100
+++ b/src/MainWindow.cpp	Wed Apr 02 09:12:18 2014 +0100
@@ -1946,15 +1946,12 @@
     if (!selections.empty()) {
         Selection sel = *selections.begin();
         m_analyser->abandonReAnalysis(sel);
+        auxSnapNotes(sel);
     }
 
     MainWindowBase::clearSelection();
 
     CommandHistory::getInstance()->endCompoundOperation();
-
-    if (!selections.empty()) {
-        auxSnapNotes(*selections.begin());
-    }
 }
 
 void
@@ -2034,11 +2031,10 @@
     for (MultiSelection::SelectionList::iterator k = selections.begin();
          k != selections.end(); ++k) {
         m_analyser->deletePitches(*k);
+        auxSnapNotes(*k);
     }
 
     CommandHistory::getInstance()->endCompoundOperation();
-
-    snapNotesToPitches();
 }
 
 void
@@ -2053,11 +2049,10 @@
          k != selections.end(); ++k) {
 
         m_analyser->shiftOctave(*k, up);
+        auxSnapNotes(*k);
     }
 
     CommandHistory::getInstance()->endCompoundOperation();
-
-    snapNotesToPitches();
 }
 
 void
@@ -2086,11 +2081,10 @@
             for (MultiSelection::SelectionList::iterator k = selections.begin();
                  k != selections.end(); ++k) {
                 m_analyser->switchPitchCandidate(*k, true);
+                auxSnapNotes(*k);
             }
 
             CommandHistory::getInstance()->endCompoundOperation();
-
-            snapNotesToPitches();
         }
     } else {
         octaveShift(true);
@@ -2111,11 +2105,10 @@
             for (MultiSelection::SelectionList::iterator k = selections.begin();
                  k != selections.end(); ++k) {
                 m_analyser->switchPitchCandidate(*k, false);
+                auxSnapNotes(*k);
             }
 
             CommandHistory::getInstance()->endCompoundOperation();
-
-            snapNotesToPitches();
         }
     } else {
         octaveShift(false);