[UI] Corrected crash when deleting multiple tracks from play queue
This commit is contained in:
@@ -501,12 +501,17 @@ PlayQueue::delSelected(void)
|
|||||||
int minId = _model->rowCount();
|
int minId = _model->rowCount();
|
||||||
Wt::WModelIndexSet indexSet = this->selectedIndexes();
|
Wt::WModelIndexSet indexSet = this->selectedIndexes();
|
||||||
|
|
||||||
|
// Make sure to delete entries in the reverse order
|
||||||
|
std::vector<int> rowIds;
|
||||||
for (Wt::WModelIndex index : indexSet)
|
for (Wt::WModelIndex index : indexSet)
|
||||||
{
|
rowIds.push_back(index.row());
|
||||||
_model->removeRow(index.row());
|
|
||||||
if (index.row() < minId)
|
std::sort(rowIds.begin(), rowIds.end(), std::greater<int>());
|
||||||
minId = index.row();
|
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
|
// If the current played track is removed, make sure to unselect it
|
||||||
_trackSelector->setSize(_model->rowCount());
|
_trackSelector->setSize(_model->rowCount());
|
||||||
|
|||||||
Reference in New Issue
Block a user