mainwindow: do not erase from container while iterating

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pavucontrol/-/merge_requests/53>
This commit is contained in:
Igor V. Kovalenko 2020-12-26 22:39:49 +03:00
parent d58e4bc592
commit 381b708202
1 changed files with 12 additions and 12 deletions

View File

@ -1260,18 +1260,18 @@ void MainWindow::removeClient(uint32_t index) {
} }
void MainWindow::removeAllWidgets() { void MainWindow::removeAllWidgets() {
for (std::map<uint32_t, SinkInputWidget*>::iterator it = sinkInputWidgets.begin(); it != sinkInputWidgets.end(); ++it) while (!sinkInputWidgets.empty())
removeSinkInput(it->first); removeSinkInput(sinkInputWidgets.begin()->first);
for (std::map<uint32_t, SourceOutputWidget*>::iterator it = sourceOutputWidgets.begin(); it != sourceOutputWidgets.end(); ++it) while (!sourceOutputWidgets.empty())
removeSourceOutput(it->first); removeSourceOutput(sourceOutputWidgets.begin()->first);
for (std::map<uint32_t, SinkWidget*>::iterator it = sinkWidgets.begin(); it != sinkWidgets.end(); ++it) while (!sinkWidgets.empty())
removeSink(it->first); removeSink(sinkWidgets.begin()->first);
for (std::map<uint32_t, SourceWidget*>::iterator it = sourceWidgets.begin(); it != sourceWidgets.end(); ++it) while (!sourceWidgets.empty())
removeSource(it->first); removeSource(sourceWidgets.begin()->first);
for (std::map<uint32_t, CardWidget*>::iterator it = cardWidgets.begin(); it != cardWidgets.end(); ++it) while (!cardWidgets.empty())
removeCard(it->first); removeCard(cardWidgets.begin()->first);
for (std::map<uint32_t, char*>::iterator it = clientNames.begin(); it != clientNames.end(); ++it) while (!clientNames.empty())
removeClient(it->first); removeClient(clientNames.begin()->first);
deleteEventRoleWidget(); deleteEventRoleWidget();
} }