summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qprogressdialog.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2014-07-29 15:31:44 +0200
committerMarc Mutz <marc.mutz@kdab.com>2014-07-30 23:39:24 +0200
commite2331c6f76bda6d19f3b4cb2b9e3cbbfe0bdc2f6 (patch)
tree585cd3051a70db5ab214a3637621848ee936c607 /src/widgets/dialogs/qprogressdialog.cpp
parent41dae1e33ae9f9eafc2c0dddef04d9c5cabe0e56 (diff)
QProgressDialog: don't crash when setting the same {bar,button,label} again
The associated test has unearthed that setBar() fails to make the new bar a child of the progress dialog. This will be fixed in a separate commit. Task-number: QTBUG-40502 Change-Id: I2d09ebb07ae6395449a4efe38a638df831eebdd7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/widgets/dialogs/qprogressdialog.cpp')
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
index 7a88e65b3c..b514b75324 100644
--- a/src/widgets/dialogs/qprogressdialog.cpp
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -354,6 +354,11 @@ QProgressDialog::~QProgressDialog()
void QProgressDialog::setLabel(QLabel *label)
{
Q_D(QProgressDialog);
+ if (label == d->label) {
+ if (label)
+ qWarning("QProgressDialog::setLabel: Attempt to set the same label again");
+ return;
+ }
delete d->label;
d->label = label;
if (label) {
@@ -411,6 +416,11 @@ void QProgressDialog::setLabelText(const QString &text)
void QProgressDialog::setCancelButton(QPushButton *cancelButton)
{
Q_D(QProgressDialog);
+ if (d->cancel == cancelButton) {
+ if (cancelButton)
+ qWarning("QProgressDialog::setCancelButton: Attempt to set the same button again");
+ return;
+ }
delete d->cancel;
d->cancel = cancelButton;
if (cancelButton) {
@@ -483,6 +493,10 @@ void QProgressDialog::setBar(QProgressBar *bar)
qWarning("QProgressDialog::setBar: Cannot set a new progress bar "
"while the old one is active");
#endif
+ if (bar == d->bar) {
+ qWarning("QProgressDialog::setBar: Attempt to set the same progress bar again");
+ return;
+ }
delete d->bar;
d->bar = bar;
int w = qMax(isVisible() ? width() : 0, sizeHint().width());