fix media delete button deleting wrong entry

the mediaSwitches UI is sorted alphabetically while the switches data strucutre is not
the previous implementation of the delete function was just using the index of the currently selected row to delete  this index of the switches data structure
the new implementation will try to find the correct entry and delete it
This commit is contained in:
WarmUpTill 2020-06-06 08:59:03 +02:00
parent 9f03264672
commit 7fef29dafb

View File

@ -73,17 +73,23 @@ void SceneSwitcher::on_mediaRemove_clicked()
if (!item)
return;
int idx = ui->mediaSwitches->currentRow();
if (idx == -1)
return;
string mediaStr =
item->data(Qt::UserRole).toString().toUtf8().constData();
{
lock_guard<mutex> lock(switcher->m);
auto &switches = switcher->mediaSwitches;
switches.erase(switches.begin() + idx);
for (auto it = switches.begin(); it != switches.end(); ++it) {
auto &s = *it;
if (s.mediaSwitchStr == mediaStr) {
switches.erase(it);
break;
}
}
}
qDeleteAll(ui->mediaSwitches->selectedItems());
delete item;
}
void SwitcherData::checkMediaSwitch(bool &match, OBSWeakSource &scene,