forked from qt-creator/qt-creator
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 <eike.ziller@qt.io>
This commit is contained in:
@@ -2189,16 +2189,18 @@ void ICorePrivate::openFileFromDevice()
|
||||
static void acceptModalDialogs()
|
||||
{
|
||||
const QWidgetList topLevels = QApplication::topLevelWidgets();
|
||||
QList<QDialog *> dialogsToClose;
|
||||
QList<QPointer<QDialog>> dialogsToClose;
|
||||
for (QWidget *topLevel : topLevels) {
|
||||
if (auto dialog = qobject_cast<QDialog *>(topLevel)) {
|
||||
if (dialog->isModal())
|
||||
dialogsToClose.append(dialog);
|
||||
}
|
||||
}
|
||||
for (QDialog *dialog : dialogsToClose)
|
||||
for (QDialog *dialog : dialogsToClose) {
|
||||
if (dialog)
|
||||
dialog->accept();
|
||||
}
|
||||
}
|
||||
|
||||
} // Internal
|
||||
|
||||
|
Reference in New Issue
Block a user