mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-05 23:40:02 +01:00
Bugfix undo of multiple sources delete
This commit is contained in:
44
Mixer.cpp
44
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<CloneSource *>(*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<CloneSource *>(*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()
|
||||
|
||||
Reference in New Issue
Block a user