From b2cff0b4bf93bc85b9b76098e8e8ff2fdaf83198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Wed, 14 Jan 2015 14:20:04 +0100 Subject: Fix stylesheet crash. Style sheets that refer to the progress bar (like "QProgressDialog[maximum='0']{}") may dereference a null-pointer during the styleHint() call in QProgressDialogPrivate::init() since the progress bar has not been created yet. Move the creation of the progress bar closer to the top of init(), before the styleHint() call. Change-Id: I31c3c1c346430fc9fe86b0977403dea0c0dc5e90 Task-number: QTBUG-43830 Reviewed-by: Andras Becsi --- src/widgets/dialogs/qprogressdialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets') diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index 01ca398a14..371949e768 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -108,10 +108,10 @@ void QProgressDialogPrivate::init(const QString &labelText, const QString &cance { Q_Q(QProgressDialog); label = new QLabel(labelText, q); - int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, 0, q); - label->setAlignment(Qt::Alignment(align)); bar = new QProgressBar(q); bar->setRange(min, max); + int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, 0, q); + label->setAlignment(Qt::Alignment(align)); autoClose = true; autoReset = true; forceHide = false; -- cgit v1.2.3