From acbfeca2b3d2cfa9467e3f88b2c1d0526e5f1ba2 Mon Sep 17 00:00:00 2001 From: Wladimir Leuschner Date: Wed, 22 Jan 2025 12:39:52 +0100 Subject: [PATCH] QWindows11Style: Default PE_IndicatorRadioButton to selected/unselected In case there is no valid QStyleOption::styleObject, default the PE_IndicatorRadioButton to the selected and unselected appearances. Fixes: QTBUG-132906 Pick-to: 6.8 Change-Id: I5e9c13cb3384321e025e5af08ee3dab81feb07fe Reviewed-by: Christian Ehrlicher (cherry picked from commit b717945812b16f957421bc2a2b1c4220f8148e64) Reviewed-by: Qt Cherry-pick Bot --- .../styles/modernwindows/qwindows11style.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/plugins/styles/modernwindows/qwindows11style.cpp b/src/plugins/styles/modernwindows/qwindows11style.cpp index 04245979dd6..13830dcdeeb 100644 --- a/src/plugins/styles/modernwindows/qwindows11style.cpp +++ b/src/plugins/styles/modernwindows/qwindows11style.cpp @@ -854,14 +854,14 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption break; case PE_IndicatorRadioButton: { - if (option->styleObject->property("_q_end_radius").isNull()) - option->styleObject->setProperty("_q_end_radius", option->state & State_On ? 4.0f :7.0f); - QNumberStyleAnimation* animation = qobject_cast(d->animation(option->styleObject)); - if (animation != nullptr) - option->styleObject->setProperty("_q_inner_radius", animation->currentValue()); - else - option->styleObject->setProperty("_q_inner_radius", option->styleObject->property("_q_end_radius")); - int innerRadius = option->styleObject->property("_q_inner_radius").toFloat(); + qreal innerRadius = option->state & State_On ? 4.0f :7.0f; + if (option->styleObject) { + if (option->styleObject->property("_q_end_radius").isNull()) + option->styleObject->setProperty("_q_end_radius", innerRadius); + QNumberStyleAnimation *animation = qobject_cast(d->animation(option->styleObject)); + innerRadius = animation ? animation->currentValue() : option->styleObject->property("_q_end_radius").toFloat(); + option->styleObject->setProperty("_q_inner_radius", innerRadius); + } QPainterPath path; QRectF rect = option->rect;