path: root/src/widgets
diff options
authorMarc Mutz <>2014-07-30 13:07:31 +0200
committerMarc Mutz <>2014-08-06 14:56:51 +0200
commite3e2e6877499ac6a151691e79d51850b9dad8941 (patch)
treee20e5bc9557bc5f66c660787d3680b7f2ef3b7e9 /src/widgets
parentf74566e08b38d11f2119daa145eda0c19f1d725b (diff)
Micro-optimize QProgressDialogPrivate::ensureSizeIsAtLeastSizeHint()
QWidget::isVisible() is an inline call, but sizeHint() is a virtual function. Use QSize operations to call each one only once. Also reduces the number of q-> qualifications needed. It must be noted that this change is not entirely behavior-preserving: If sizeHint() returns a negative component, and the dialog is not visible, resize() will be called with that negative component now, instead of zero as was the case previously. I believe this is not a problem, because the way sizeHint() is currently implemented, the width cannot be less than 200 and for the height to be negative, the sum of label, bar and button size hint height would need to be negative, which is next to impossible. Change-Id: Ie8ba110e193532921eb4732a0393a377e38d7f7e Reviewed-by: David Faure <> Reviewed-by: Friedemann Kleint <>
Diffstat (limited to 'src/widgets')
1 files changed, 4 insertions, 3 deletions
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index 4a2b5cbea9..ed856c266e 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -505,9 +505,10 @@ void QProgressDialogPrivate::ensureSizeIsAtLeastSizeHint()
- int w = qMax(q->isVisible() ? q->width() : 0, q->sizeHint().width());
- int h = qMax(q->isVisible() ? q->height() : 0, q->sizeHint().height());
- q->resize(w, h);
+ QSize size = q->sizeHint();
+ if (q->isVisible())
+ size = size.expandedTo(q->size());
+ q->resize(size);