summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-07-30 13:07:31 +0200
committerMarc Mutz <marc.mutz@kdab.com>2014-08-06 14:56:51 +0200
commite3e2e6877499ac6a151691e79d51850b9dad8941 (patch)
treee20e5bc9557bc5f66c660787d3680b7f2ef3b7e9 /src/widgets/dialogs
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 <david.faure@kdab.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp7
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()
{
Q_Q(QProgressDialog);
- 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);
}