diff options
author | Liang Qi <liang.qi@qt.io> | 2017-02-08 15:48:29 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-02-08 15:49:18 +0100 |
commit | dd756011da13b95fdb630a1bbb90234f1e60f415 (patch) | |
tree | a6259b1e9b6463108796ce912e3d1752e301505f /src/widgets/dialogs | |
parent | 0c50edbe84914469973a3b10e0170023ccdd66fe (diff) | |
parent | b6bf2a33f4c33a212da7b58a049b3b5b20b3f327 (diff) |
Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts:
configure.json
mkspecs/win32-icc/qmake.conf
Change-Id: Ibf40546b024d644c7d9ed490bee15b82597f4d3f
Diffstat (limited to 'src/widgets/dialogs')
-rw-r--r-- | src/widgets/dialogs/qdialog.cpp | 2 | ||||
-rw-r--r-- | src/widgets/dialogs/qdialog_p.h | 18 | ||||
-rw-r--r-- | src/widgets/dialogs/qinputdialog.cpp | 106 |
3 files changed, 60 insertions, 66 deletions
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index e8883df527..e5715ecd57 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -557,8 +557,8 @@ int QDialog::exec() void QDialog::done(int r) { Q_D(QDialog); - hide(); setResult(r); + hide(); d->close_helper(QWidgetPrivate::CloseNoEvent); d->resetModalitySetByOpen(); diff --git a/src/widgets/dialogs/qdialog_p.h b/src/widgets/dialogs/qdialog_p.h index 1c7c5f3c2a..ae9e3bcc93 100644 --- a/src/widgets/dialogs/qdialog_p.h +++ b/src/widgets/dialogs/qdialog_p.h @@ -119,6 +119,24 @@ private: mutable bool m_platformHelperCreated; }; +template <typename T> +class QAutoPointer { + QPointer<T> o; + struct internal { void func() {} }; + typedef void (internal::*RestrictedBool)(); +public: + explicit QAutoPointer(T *t) Q_DECL_NOTHROW : o(t) {} + ~QAutoPointer() { delete o; } + + T *operator->() const Q_DECL_NOTHROW { return get(); } + T *get() const Q_DECL_NOTHROW { return o; } + T &operator*() const { return *get(); } + operator RestrictedBool() const Q_DECL_NOTHROW { return o ? &internal::func : Q_NULLPTR; } + bool operator!() const Q_DECL_NOTHROW { return !o; } +private: + Q_DISABLE_COPY(QAutoPointer); +}; + QT_END_NAMESPACE #endif // QDIALOG_P_H diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp index d09f77ea35..4ca3923d8d 100644 --- a/src/widgets/dialogs/qinputdialog.cpp +++ b/src/widgets/dialogs/qinputdialog.cpp @@ -1194,10 +1194,6 @@ void QInputDialog::done(int result) \snippet dialogs/standarddialogs/dialog.cpp 3 - \warning Do not delete \a parent during the execution of the dialog. If you - want to do this, you should create the dialog yourself using one of the - QInputDialog constructors. - \sa getInt(), getDouble(), getItem(), getMultiLineText() */ @@ -1205,18 +1201,18 @@ QString QInputDialog::getText(QWidget *parent, const QString &title, const QStri QLineEdit::EchoMode mode, const QString &text, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) { - QInputDialog dialog(parent, flags); - dialog.setWindowTitle(title); - dialog.setLabelText(label); - dialog.setTextValue(text); - dialog.setTextEchoMode(mode); - dialog.setInputMethodHints(inputMethodHints); + QAutoPointer<QInputDialog> dialog(new QInputDialog(parent, flags)); + dialog->setWindowTitle(title); + dialog->setLabelText(label); + dialog->setTextValue(text); + dialog->setTextEchoMode(mode); + dialog->setInputMethodHints(inputMethodHints); - int ret = dialog.exec(); + const int ret = dialog->exec(); if (ok) *ok = !!ret; if (ret) { - return dialog.textValue(); + return dialog->textValue(); } else { return QString(); } @@ -1246,10 +1242,6 @@ QString QInputDialog::getText(QWidget *parent, const QString &title, const QStri \snippet dialogs/standarddialogs/dialog.cpp 4 - \warning Do not delete \a parent during the execution of the dialog. If you - want to do this, you should create the dialog yourself using one of the - QInputDialog constructors. - \sa getInt(), getDouble(), getItem(), getText() */ @@ -1257,18 +1249,18 @@ QString QInputDialog::getMultiLineText(QWidget *parent, const QString &title, co const QString &text, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) { - QInputDialog dialog(parent, flags); - dialog.setOptions(QInputDialog::UsePlainTextEditForTextInput); - dialog.setWindowTitle(title); - dialog.setLabelText(label); - dialog.setTextValue(text); - dialog.setInputMethodHints(inputMethodHints); + QAutoPointer<QInputDialog> dialog(new QInputDialog(parent, flags)); + dialog->setOptions(QInputDialog::UsePlainTextEditForTextInput); + dialog->setWindowTitle(title); + dialog->setLabelText(label); + dialog->setTextValue(text); + dialog->setInputMethodHints(inputMethodHints); - int ret = dialog.exec(); + const int ret = dialog->exec(); if (ok) *ok = !!ret; if (ret) { - return dialog.textValue(); + return dialog->textValue(); } else { return QString(); } @@ -1298,28 +1290,24 @@ QString QInputDialog::getMultiLineText(QWidget *parent, const QString &title, co \snippet dialogs/standarddialogs/dialog.cpp 0 - \warning Do not delete \a parent during the execution of the dialog. If you - want to do this, you should create the dialog yourself using one of the - QInputDialog constructors. - \sa getText(), getDouble(), getItem(), getMultiLineText() */ int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &label, int value, int min, int max, int step, bool *ok, Qt::WindowFlags flags) { - QInputDialog dialog(parent, flags); - dialog.setWindowTitle(title); - dialog.setLabelText(label); - dialog.setIntRange(min, max); - dialog.setIntValue(value); - dialog.setIntStep(step); + QAutoPointer<QInputDialog> dialog(new QInputDialog(parent, flags)); + dialog->setWindowTitle(title); + dialog->setLabelText(label); + dialog->setIntRange(min, max); + dialog->setIntValue(value); + dialog->setIntStep(step); - int ret = dialog.exec(); + const int ret = dialog->exec(); if (ok) *ok = !!ret; if (ret) { - return dialog.intValue(); + return dialog->intValue(); } else { return value; } @@ -1350,10 +1338,6 @@ int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &l \snippet dialogs/standarddialogs/dialog.cpp 0 - \warning Do not delete \a parent during the execution of the dialog. If you - want to do this, you should create the dialog yourself using one of the - QInputDialog constructors. - \sa getText(), getDouble(), getItem(), getMultiLineText() */ @@ -1379,10 +1363,6 @@ int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &l \snippet dialogs/standarddialogs/dialog.cpp 1 - \warning Do not delete \a parent during the execution of the dialog. If you - want to do this, you should create the dialog yourself using one of the - QInputDialog constructors. - \sa getText(), getInt(), getItem(), getMultiLineText() */ @@ -1390,18 +1370,18 @@ double QInputDialog::getDouble(QWidget *parent, const QString &title, const QStr double value, double min, double max, int decimals, bool *ok, Qt::WindowFlags flags) { - QInputDialog dialog(parent, flags); - dialog.setWindowTitle(title); - dialog.setLabelText(label); - dialog.setDoubleDecimals(decimals); - dialog.setDoubleRange(min, max); - dialog.setDoubleValue(value); + QAutoPointer<QInputDialog> dialog(new QInputDialog(parent, flags)); + dialog->setWindowTitle(title); + dialog->setLabelText(label); + dialog->setDoubleDecimals(decimals); + dialog->setDoubleRange(min, max); + dialog->setDoubleValue(value); - int ret = dialog.exec(); + const int ret = dialog->exec(); if (ok) *ok = !!ret; if (ret) { - return dialog.doubleValue(); + return dialog->doubleValue(); } else { return value; } @@ -1433,10 +1413,6 @@ double QInputDialog::getDouble(QWidget *parent, const QString &title, const QStr \snippet dialogs/standarddialogs/dialog.cpp 2 - \warning Do not delete \a parent during the execution of the dialog. If you - want to do this, you should create the dialog yourself using one of the - QInputDialog constructors. - \sa getText(), getInt(), getDouble(), getMultiLineText() */ @@ -1446,19 +1422,19 @@ QString QInputDialog::getItem(QWidget *parent, const QString &title, const QStri { QString text(items.value(current)); - QInputDialog dialog(parent, flags); - dialog.setWindowTitle(title); - dialog.setLabelText(label); - dialog.setComboBoxItems(items); - dialog.setTextValue(text); - dialog.setComboBoxEditable(editable); - dialog.setInputMethodHints(inputMethodHints); + QAutoPointer<QInputDialog> dialog(new QInputDialog(parent, flags)); + dialog->setWindowTitle(title); + dialog->setLabelText(label); + dialog->setComboBoxItems(items); + dialog->setTextValue(text); + dialog->setComboBoxEditable(editable); + dialog->setInputMethodHints(inputMethodHints); - int ret = dialog.exec(); + const int ret = dialog->exec(); if (ok) *ok = !!ret; if (ret) { - return dialog.textValue(); + return dialog->textValue(); } else { return text; } |