Fix broken playlist undostack when i.e. removing duplicates and unavailable songs

This commit is contained in:
Jonas Kvinge
2020-07-08 20:43:46 +02:00
parent aba7d2b6a4
commit a99a19aa60
4 changed files with 10 additions and 16 deletions

View File

@@ -930,7 +930,8 @@ void Playlist::InsertItems(const PlaylistItemList &itemsIn, int pos, bool play_n
// Too big to keep in the undo stack. Also clear the stack because it might have been invalidated.
InsertItemsWithoutUndo(items, pos, enqueue, enqueue_next);
undo_stack_->clear();
} else {
}
else {
undo_stack_->push(new PlaylistUndoCommands::InsertItems(this, items, pos, enqueue, enqueue_next));
}
@@ -1384,6 +1385,8 @@ void Playlist::RemoveItemsWithoutUndo(const QList<int> &indicesIn) {
bool Playlist::removeRows(int row, int count, const QModelIndex &parent) {
Q_UNUSED(parent);
if (row < 0 || row >= items_.size() || row + count > items_.size()) {
return false;
}
@@ -1393,9 +1396,6 @@ bool Playlist::removeRows(int row, int count, const QModelIndex &parent) {
RemoveItemsWithoutUndo(row, count);
undo_stack_->clear();
}
else if (parent == QModelIndex()) {
RemoveItemsWithoutUndo(row, count);
}
else {
undo_stack_->push(new PlaylistUndoCommands::RemoveItems(this, row, count));
}