comparison 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
comparison
equal deleted inserted replaced
251:3b5ea600829c 252:f99fae5fe89c
281 QString 281 QString
282 Analyser::reAnalyseSelection(Selection sel, FrequencyRange range) 282 Analyser::reAnalyseSelection(Selection sel, FrequencyRange range)
283 { 283 {
284 if (sel == m_reAnalysingSelection || sel.isEmpty()) return ""; 284 if (sel == m_reAnalysingSelection || sel.isEmpty()) return "";
285 285
286 discardPitchCandidates(); 286 if (!m_reAnalysisCandidates.empty()) {
287 CommandHistory::getInstance()->startCompoundOperation
288 (tr("Discard Previous Candidates"), true);
289 discardPitchCandidates();
290 CommandHistory::getInstance()->endCompoundOperation();
291 }
287 292
288 m_reAnalysingSelection = sel; 293 m_reAnalysingSelection = sel;
289 294
290 m_preAnalysis = Clipboard(); 295 m_preAnalysis = Clipboard();
291 Layer *myLayer = m_layers[PitchTrack]; 296 Layer *myLayer = m_layers[PitchTrack];
527 } 532 }
528 533
529 void 534 void
530 Analyser::abandonReAnalysis(Selection sel) 535 Analyser::abandonReAnalysis(Selection sel)
531 { 536 {
537 // A compound command is already in progress
538
532 discardPitchCandidates(); 539 discardPitchCandidates();
533 540
534 Layer *myLayer = m_layers[PitchTrack]; 541 Layer *myLayer = m_layers[PitchTrack];
535 if (!myLayer) return; 542 if (!myLayer) return;
536 myLayer->deleteSelection(sel); 543 myLayer->deleteSelection(sel);
539 546
540 void 547 void
541 Analyser::discardPitchCandidates() 548 Analyser::discardPitchCandidates()
542 { 549 {
543 if (!m_reAnalysisCandidates.empty()) { 550 if (!m_reAnalysisCandidates.empty()) {
544 551 // We don't use a compound command here, because we may be
545 CommandHistory::getInstance()->startCompoundOperation 552 // already in one. Caller bears responsibility for doing that
546 (tr("Discard Previous Candidates"), true);
547
548 foreach (Layer *layer, m_reAnalysisCandidates) { 553 foreach (Layer *layer, m_reAnalysisCandidates) {
549 // This will cause the layer to be deleted later (ownership is 554 // This will cause the layer to be deleted later (ownership is
550 // transferred to the remove command) 555 // transferred to the remove command)
551 m_document->removeLayerFromView(m_pane, layer); 556 m_document->removeLayerFromView(m_pane, layer);
552 } 557 }
553
554 m_reAnalysisCandidates.clear(); 558 m_reAnalysisCandidates.clear();
555 CommandHistory::getInstance()->endCompoundOperation();
556 } 559 }
557 560
558 m_currentCandidate = -1; 561 m_currentCandidate = -1;
559 m_reAnalysingSelection = Selection(); 562 m_reAnalysingSelection = Selection();
560 m_candidatesVisible = false; 563 m_candidatesVisible = false;