copy the buffer to allow modifications during iteration

This commit is contained in:
Sébastien Loriot 2023-12-01 11:52:20 +01:00
parent 120547bee7
commit a8c58f8747
1 changed files with 2 additions and 1 deletions

View File

@ -376,7 +376,8 @@ void filterMenuOperations(QMenu* menu, QString filter, bool keep_from_here)
buffer.append(action); buffer.append(action);
while(!buffer.isEmpty()){ while(!buffer.isEmpty()){
for(QAction* action : buffer) { QList<QAction*> buffer_copy=buffer; // make a copy as we modify buffer in the loop
for(QAction* action : buffer_copy) {
if(QMenu* submenu = action->menu()) if(QMenu* submenu = action->menu())
{ {
bool keep = true; bool keep = true;