diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 76904aaadd..06de5566ff 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -1455,6 +1455,9 @@ QComboBox::~QComboBox() } QT_CATCH(...) { ; // objects can't throw in destructor } + + // Dispose of container before QComboBox goes away + delete d->container; } /*! diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h index 6ea0065d8c..723d637ae2 100644 --- a/src/widgets/widgets/qcombobox_p.h +++ b/src/widgets/widgets/qcombobox_p.h @@ -380,7 +380,7 @@ public: std::array modelConnections; QAbstractItemModel *model = nullptr; QLineEdit *lineEdit = nullptr; - QComboBoxPrivateContainer *container = nullptr; + QPointer container; #ifdef Q_OS_MAC QPlatformMenu *m_platformMenu = nullptr; #endif