From 38cdbd2bcd6c11c69e2b03fd309df632acd70621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20L=C3=B6hning?= Date: Mon, 7 Mar 2022 22:30:20 +0100 Subject: [PATCH] ManhattanStyle: Avoid crash when zooming invalid image Task-number: QTBUG-101581 Change-Id: I4070efe266fbbd579b021cd9c03465c85313e042 Reviewed-by: Eike Ziller Reviewed-by: Qt CI Bot --- src/plugins/coreplugin/manhattanstyle.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp index a6b94660f6f..d4a4cdbe6f5 100644 --- a/src/plugins/coreplugin/manhattanstyle.cpp +++ b/src/plugins/coreplugin/manhattanstyle.cpp @@ -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(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); }