QProxyStyle: reimplement event() handling

There is no use case for QProxyStyle to forward events to its base
style. QApplication does not send events to it; a style using e.g.
timers or so will have them active on *itself*, not on the proxy.

Moreover, forwarding *all* events is broken: QTBUG-96213 has been
triggered by forwarding DeferredDelete events sent to the proxy (thus
accidentally deleting the base style). But one can concoct many other
similarly broken situations; for instance, setting a proxy onto a base
style will make the style a child of the proxy.  That sends a
QChildEvent to the proxy (ChildAdded), and that event is then passed on
the base style, resulting in the base style receiving an event saying
"you have yourself as a child".

Change-Id: I3b92bb168ce3c54a32469c36b6d1da4380ed564f
Reviewed-by: Rafael Roquetto <rafael.roquetto@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
bb10
Giuseppe D'Angelo 2022-04-07 15:24:14 +02:00
parent 09e9f45933
commit 5d8a7652b9
1 changed files with 2 additions and 7 deletions

View File

@ -382,13 +382,8 @@ void QProxyStyle::unpolish(QApplication *app)
*/
bool QProxyStyle::event(QEvent *e)
{
Q_D (QProxyStyle);
if (e->type() == QEvent::DeferredDelete)
return QCommonStyle::event(e);
d->ensureBaseStyle();
return d->baseStyle->event(e);
// ### Qt 7: remove this override
return QCommonStyle::event(e);
}
/*!