QComboBox: Revert recreation of ComboBox Container on style change

In commit 9da8d67b3bca1d40ae221a9c6be218fe57759724 a recreation of the
ComboBox Container was introduced, since QWindows11Style depends on
WA_TranslucentBackground flag, whereas the other styles don't set this
flag. This leads to the destruction of user supplied views we don't own.

Fixes: QTBUG-124191
Change-Id: I4a693f612ddc299696b9de0d87c94d88c04d9b39
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 61b71ffb3b2b34aea67306c973ee751335733433)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Wladimir Leuschner 2024-04-09 10:44:22 +02:00 committed by Qt Cherry-pick Bot
parent 6c67572181
commit 917a0bf265

View File

@ -3003,24 +3003,8 @@ void QComboBox::changeEvent(QEvent *e)
Q_D(QComboBox);
switch (e->type()) {
case QEvent::StyleChange:
if (d->container) {
// If on Windows, force recreation of ComboBox container, since
// windows11 style depends on WA_TranslucentBackground
#ifdef Q_OS_WIN
auto delegate = itemDelegate();
d->container->deleteLater();
// d->container needs to be set explicitly to nullptr
// since QComboBoxPrivate::viewContainer() only
// creates a new QComboBoxPrivateContainer when
// d->container has the value of nullptr
d->container = nullptr;
d->container = d->viewContainer();
delegate->setParent(d->container);
setItemDelegate(delegate);
#endif
if (d->container)
d->container->updateStyleSettings();
}
d->updateDelegate();
#ifdef Q_OS_MAC