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,15 +2189,17 @@ void ICorePrivate::openFileFromDevice()
|
|||||||
static void acceptModalDialogs()
|
static void acceptModalDialogs()
|
||||||
{
|
{
|
||||||
const QWidgetList topLevels = QApplication::topLevelWidgets();
|
const QWidgetList topLevels = QApplication::topLevelWidgets();
|
||||||
QList<QDialog *> dialogsToClose;
|
QList<QPointer<QDialog>> dialogsToClose;
|
||||||
for (QWidget *topLevel : topLevels) {
|
for (QWidget *topLevel : topLevels) {
|
||||||
if (auto dialog = qobject_cast<QDialog *>(topLevel)) {
|
if (auto dialog = qobject_cast<QDialog *>(topLevel)) {
|
||||||
if (dialog->isModal())
|
if (dialog->isModal())
|
||||||
dialogsToClose.append(dialog);
|
dialogsToClose.append(dialog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (QDialog *dialog : dialogsToClose)
|
for (QDialog *dialog : dialogsToClose) {
|
||||||
|
if (dialog)
|
||||||
dialog->accept();
|
dialog->accept();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
|
Reference in New Issue
Block a user