diff options
Diffstat (limited to 'src/widgets/dialogs/qprogressdialog.cpp')
-rw-r--r-- | src/widgets/dialogs/qprogressdialog.cpp | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp index 662504fc25..35a75adea2 100644 --- a/src/widgets/dialogs/qprogressdialog.cpp +++ b/src/widgets/dialogs/qprogressdialog.cpp @@ -84,6 +84,7 @@ public: void init(const QString &labelText, const QString &cancelText, int min, int max); void layout(); void retranslateStrings(); + void setCancelButtonText(const QString &cancelButtonText); void _q_disconnectOnClose(); QLabel *label; @@ -178,9 +179,8 @@ void QProgressDialogPrivate::layout() void QProgressDialogPrivate::retranslateStrings() { - Q_Q(QProgressDialog); if (useDefaultCancelText) - q->setCancelButtonText(QProgressDialog::tr("Cancel")); + setCancelButtonText(QProgressDialog::tr("Cancel")); } void QProgressDialogPrivate::_q_disconnectOnClose() @@ -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) { @@ -448,19 +458,25 @@ void QProgressDialog::setCancelButtonText(const QString &cancelButtonText) { Q_D(QProgressDialog); d->useDefaultCancelText = false; + d->setCancelButtonText(cancelButtonText); +} + +void QProgressDialogPrivate::setCancelButtonText(const QString &cancelButtonText) +{ + Q_Q(QProgressDialog); if (!cancelButtonText.isNull()) { - if (d->cancel) { - d->cancel->setText(cancelButtonText); + if (cancel) { + cancel->setText(cancelButtonText); } else { - setCancelButton(new QPushButton(cancelButtonText, this)); + q->setCancelButton(new QPushButton(cancelButtonText, q)); } } else { - setCancelButton(0); + q->setCancelButton(0); } - int w = qMax(isVisible() ? width() : 0, sizeHint().width()); - int h = qMax(isVisible() ? height() : 0, sizeHint().height()); - resize(w, h); + 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); } @@ -483,6 +499,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()); @@ -507,7 +527,7 @@ bool QProgressDialog::wasCanceled() const \property QProgressDialog::maximum \brief the highest value represented by the progress bar - The default is 0. + The default is 100. \sa minimum, setRange() */ |