1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-16 03:09:57 +01:00

Make sure current_virtual_index_ is kept consistent when clearing or deleting items from the playlist. Fixes issue #107

This commit is contained in:
David Sansome 2010-03-24 14:37:10 +00:00
parent 92c7eff0fb
commit 4b4603e138

View File

@ -580,17 +580,19 @@ bool Playlist::removeRows(int row, int count, const QModelIndex& parent) {
QList<int>::iterator it = virtual_items_.begin();
int i = 0;
while (it != virtual_items_.end()) {
if (*it >= items_.count()) {
if (i >= current_virtual_index_)
current_virtual_index_ --;
if (*it >= items_.count())
it = virtual_items_.erase(it);
} else {
else
++it;
}
++i;
}
// Reset current_virtual_index_
if (current_index() == -1)
current_virtual_index_ = -1;
else
current_virtual_index_ = virtual_items_.indexOf(current_index());
Save();
return true;
}
@ -683,6 +685,8 @@ void Playlist::Clear() {
virtual_items_.clear();
reset();
current_virtual_index_ = -1;
Save();
}