From 8a3c4c8283e4762744a29262ce507713565c1c0c Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 22 Dec 2010 17:13:30 +0100 Subject: Fix crash in indeterminate progressbars on windows Note that this is a surgical fix for 4.7 only. In 4.8 we will add these checks at the top of the styling functions or in the widgets instead. Task-number:QTBUG-15227 Reviewed-by:gabi --- src/gui/styles/qcommonstyle.cpp | 5 +++-- src/gui/styles/qwindowsstyle.cpp | 4 +++- tests/auto/qstyle/tst_qstyle.cpp | 7 +++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index 039a6da..1d7c838 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -1403,8 +1403,9 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, } break; case CE_ProgressBarGroove: - qDrawShadePanel(p, opt->rect, opt->palette, true, 1, - &opt->palette.brush(QPalette::Window)); + if (opt->rect.isValid()) + qDrawShadePanel(p, opt->rect, opt->palette, true, 1, + &opt->palette.brush(QPalette::Window)); break; case CE_ProgressBarLabel: if (const QStyleOptionProgressBar *pb = qstyleoption_cast(opt)) { diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index 654be3c..32a6d8d 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -2397,8 +2397,10 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai #ifndef QT_NO_PROGRESSBAR case CE_ProgressBarContents: if (const QStyleOptionProgressBar *pb = qstyleoption_cast(opt)) { - QRect rect = pb->rect; + if (!rect.isValid()) + return; + bool vertical = false; bool inverted = false; diff --git a/tests/auto/qstyle/tst_qstyle.cpp b/tests/auto/qstyle/tst_qstyle.cpp index ba24225..9c754d2 100644 --- a/tests/auto/qstyle/tst_qstyle.cpp +++ b/tests/auto/qstyle/tst_qstyle.cpp @@ -413,6 +413,13 @@ void tst_QStyle::testWindowsStyle() QWindowsStyle wstyle; testAllFunctions(&wstyle); lineUpLayoutTest(&wstyle); + + // Tests drawing indeterminate progress with 0 size: QTBUG-15973 + QStyleOptionProgressBar pb; + pb.rect = QRect(0,0,-9,0); + QPixmap surface(QSize(200, 200)); + QPainter painter(&surface); + wstyle.drawControl(QStyle::CE_ProgressBar, &pb, &painter, 0); } void tst_QStyle::testWindowsXPStyle() -- cgit v0.12