ManhattanStyle: Avoid crash when zooming invalid image

Task-number: QTBUG-101581
Change-Id: I4070efe266fbbd579b021cd9c03465c85313e042
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Robert Löhning
2022-03-07 22:30:20 +01:00
parent 860d8548ec
commit 38cdbd2bcd

View File

@@ -189,6 +189,14 @@ QRect ManhattanStyle::subElementRect(SubElement element, const QStyleOption *opt
QRect ManhattanStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
SubControl subControl, const QWidget *widget) const
{
#if QT_VERSION < QT_VERSION_CHECK(6, 2, 5)
// Workaround for QTBUG-101581, can be removed when building with Qt 6.2.5 or higher
if (control == CC_ScrollBar) {
const auto scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(option);
if (scrollbar && qint64(scrollbar->maximum) - scrollbar->minimum > INT_MAX)
return QRect(); // breaks the scrollbar, but avoids the crash
}
#endif
return QProxyStyle::subControlRect(control, option, subControl, widget);
}