diff options
| author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2025-09-04 20:04:25 +0200 |
|---|---|---|
| committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2025-09-22 21:56:45 +0000 |
| commit | 14aa698cc310dbe77b94752d80054fc4086d5c26 (patch) | |
| tree | 7d71d95e7163b37cd38dbb845d718fd1fb473c7f /src/widgets/kernel/qwidget.cpp | |
| parent | 71707eadfafceddc307237b2d73762053ef27f26 (diff) | |
QWidget: fix propagating style with descendant selectors
The fix for QTBUG-133332 introduced a check to avoid an endless
recursion within setStyle_helper() but it prevents the correct
propagation of the style with a descendant selector. Therefore use
another approach and make sure QWidgetPrivate::inheritStyle() is not
called recursivly.
This amends 3252e1808c12c21f27bb4844a1497d18587a64b5.
Pick-to: 6.10 6.9
Task-number: QTBUG-133332
Fixes: QTBUG-139924
Change-Id: Ia0a1eec652380397f861364bbdc303dfd17b34f3
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
| -rw-r--r-- | src/widgets/kernel/qwidget.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index d81632cfbe2..cddf5833fa0 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -161,6 +161,7 @@ QWidgetPrivate::QWidgetPrivate(decltype(QObjectPrivateVersion) version) , childrenHiddenByWState(0) , childrenShownByExpose(0) , dontSetExplicitShowHide(0) + , inheritStyleRecursionGuard(0) #if defined(Q_OS_WIN) , noPaintOnScreen(0) #endif @@ -2692,7 +2693,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate) extra->style = newStyle; // repolish - if (polished && q->windowType() != Qt::Desktop && oldStyle != q->style()) { + if (polished && q->windowType() != Qt::Desktop) { oldStyle->unpolish(q); q->style()->polish(q); } @@ -2740,6 +2741,12 @@ void QWidgetPrivate::inheritStyle() proxy->repolish(q); return; } + if (inheritStyleRecursionGuard) + return; + inheritStyleRecursionGuard = true; + const auto resetGuard = qScopeGuard([&]() { + inheritStyleRecursionGuard = false; + }); QStyle *origStyle = proxy ? proxy->base : extraStyle; QWidget *parent = q->parentWidget(); |
