diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2024-03-03 22:06:06 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2024-03-09 13:52:19 +0100 |
commit | fde358dd9069d0695f113ec6ba98efebedd1e520 (patch) | |
tree | 497ec5c6cc64842bb8af0c41b1fc7709ded0f1df /src/widgets | |
parent | 0fa0d01c3673c7f68b5820869c444421c0591ca1 (diff) |
Delete QComboBoxPrivateContainer while the combo box is still alive
Destroying the QComboxBox will, once it reaches the QWidget destructor,
close all popups, including the QComboBoxPrivateContainer, which emits
signals on behalf of the QComboBox, that is now gone.
Regression after d8e110054876b1cbf186e95bac5561a237ee1c13.
The old-syle signal-slot syntax had the advantage of not delivering
signals to slots in derived classes after that derived class's
destructor had finished running (because we called via the virtual
qt_metacall). The new syntax made no checks, so a conversion from the
old to the new syntax may introduce crashes or other data corruptions
at runtime if the destructor had completed.
See 0e72a846d379ba02ff80ecac2526640a05b872b6.
We also need a QPointer for the QComboBoxPrivateContainer, as the
container may be deleted from outside QComboBox, as seen in the
tst_QGraphicsProxyWidget::bypassGraphicsProxyWidget() test, where
the QGraphicsProxyWidget proxies the QComboBoxPrivateContainer.
Pick-to: 6.7 6.6 6.5
Change-Id: I7590cc2821c73a6762f281504aa62f0c2b472252
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 3 | ||||
-rw-r--r-- | src/widgets/widgets/qcombobox_p.h | 2 |
2 files changed, 4 insertions, 1 deletions
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<QMetaObject::Connection, 8> modelConnections; QAbstractItemModel *model = nullptr; QLineEdit *lineEdit = nullptr; - QComboBoxPrivateContainer *container = nullptr; + QPointer<QComboBoxPrivateContainer> container; #ifdef Q_OS_MAC QPlatformMenu *m_platformMenu = nullptr; #endif |