diff --git a/Mixer.cpp b/Mixer.cpp index a82b4a2..6b5ce14 100644 --- a/Mixer.cpp +++ b/Mixer.cpp @@ -566,22 +566,36 @@ void Mixer::deselect(Source *s) void Mixer::deleteSelection() { - // get clones first : this way we store the history of deletion in the right order - SourceList selection_clones_; - for ( auto sit = selection().begin(); sit != selection().end(); sit++ ) { - CloneSource *clone = dynamic_cast(*sit); - if (clone) - selection_clones_.push_back(clone); - } - // delete all clones - while ( !selection_clones_.empty() ) { - deleteSource( selection_clones_.front()); - selection_clones_.pop_front(); - } - // empty the selection - while ( !selection().empty() ) - deleteSource( selection().front() ); // this also remove element from selection() + // number of sources in selection + int N = selection().size(); + // ignore if selection empty + if (N > 0) { + // adapt Action::manager undo action depending on case + std::string undomessage; + if (N > 1) + undomessage = std::to_string(N) + std::string(" sources deleted"); + else + undomessage = selection().front()->name() + std::string(" deleted"); + + // get clones first : this way we store the history of deletion in the right order + SourceList selection_clones_; + for ( auto sit = selection().begin(); sit != selection().end(); sit++ ) { + CloneSource *clone = dynamic_cast(*sit); + if (clone) + selection_clones_.push_back(clone); + } + // delete all clones + while ( !selection_clones_.empty() ) { + deleteSource( selection_clones_.front(), false);// this also removes element from selection() + selection_clones_.pop_front(); + } + // empty the selection + while ( !selection().empty() ) + deleteSource( selection().front(), false ); // this also removes element from selection() + + Action::manager().store( undomessage ); + } } void Mixer::groupSelection()