From 6d6ec00cdbb6d110411ed8b731790ab676417d41 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 4 Mar 2024 14:50:27 +0100 Subject: [PATCH] Core: Wrap moribund dialogs into QPointer There's no guarantee that items in the collected list don't die for other reasons before it's their turn in the loop. Change-Id: I5e81a25c3c205646eece30d6dd1a95f4b97eda05 Reviewed-by: Eike Ziller --- src/plugins/coreplugin/icore.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index 54462f30512..1834a795608 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -2189,15 +2189,17 @@ void ICorePrivate::openFileFromDevice() static void acceptModalDialogs() { const QWidgetList topLevels = QApplication::topLevelWidgets(); - QList dialogsToClose; + QList> dialogsToClose; for (QWidget *topLevel : topLevels) { if (auto dialog = qobject_cast(topLevel)) { if (dialog->isModal()) dialogsToClose.append(dialog); } } - for (QDialog *dialog : dialogsToClose) - dialog->accept(); + for (QDialog *dialog : dialogsToClose) { + if (dialog) + dialog->accept(); + } } } // Internal