mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-16 11:19:18 +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:
parent
92c7eff0fb
commit
4b4603e138
@ -580,17 +580,19 @@ bool Playlist::removeRows(int row, int count, const QModelIndex& parent) {
|
|||||||
QList<int>::iterator it = virtual_items_.begin();
|
QList<int>::iterator it = virtual_items_.begin();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (it != virtual_items_.end()) {
|
while (it != virtual_items_.end()) {
|
||||||
if (*it >= items_.count()) {
|
if (*it >= items_.count())
|
||||||
if (i >= current_virtual_index_)
|
|
||||||
current_virtual_index_ --;
|
|
||||||
|
|
||||||
it = virtual_items_.erase(it);
|
it = virtual_items_.erase(it);
|
||||||
} else {
|
else
|
||||||
++it;
|
++it;
|
||||||
}
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset current_virtual_index_
|
||||||
|
if (current_index() == -1)
|
||||||
|
current_virtual_index_ = -1;
|
||||||
|
else
|
||||||
|
current_virtual_index_ = virtual_items_.indexOf(current_index());
|
||||||
|
|
||||||
Save();
|
Save();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -683,6 +685,8 @@ void Playlist::Clear() {
|
|||||||
virtual_items_.clear();
|
virtual_items_.clear();
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
|
current_virtual_index_ = -1;
|
||||||
|
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user