[UI] Corrected crash when deleting multiple tracks from play queue

This commit is contained in:
emeric
2015-08-05 12:31:57 +02:00
parent 0742e1d681
commit 2a7f5ae886
+10 -5
View File
@@ -501,12 +501,17 @@ PlayQueue::delSelected(void)
int minId = _model->rowCount();
Wt::WModelIndexSet indexSet = this->selectedIndexes();
// Make sure to delete entries in the reverse order
std::vector<int> rowIds;
for (Wt::WModelIndex index : indexSet)
{
_model->removeRow(index.row());
if (index.row() < minId)
minId = index.row();
}
rowIds.push_back(index.row());
std::sort(rowIds.begin(), rowIds.end(), std::greater<int>());
if (!rowIds.empty())
minId = rowIds.back();
for (int rowId : rowIds)
_model->removeRow(rowId);
// If the current played track is removed, make sure to unselect it
_trackSelector->setSize(_model->rowCount());