summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qdialogbuttonbox.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@theqtcompany.com>2015-06-04 05:56:06 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2015-06-04 05:56:06 +0000
commitccad00121d0a9d703cf715c54347b32bfc33bbfc (patch)
tree8e492f00f9ea81d87ae9126ad06c3dbc21fee3a3 /src/widgets/widgets/qdialogbuttonbox.cpp
parentdc2617f35be61b4827b8e3d192c85e2feacf7f6a (diff)
parente2f66f921594b7be4af4a058c959557489e86879 (diff)
Merge "Merge remote-tracking branch 'origin/5.5' into dev" into refs/staging/dev
Diffstat (limited to 'src/widgets/widgets/qdialogbuttonbox.cpp')
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
index 237eb775b9..3e8c08f923 100644
--- a/src/widgets/widgets/qdialogbuttonbox.cpp
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -852,9 +852,19 @@ void QDialogButtonBoxPrivate::_q_handleButtonClicked()
{
Q_Q(QDialogButtonBox);
if (QAbstractButton *button = qobject_cast<QAbstractButton *>(q->sender())) {
+ // Can't fetch this *after* emitting clicked, as clicked may destroy the button
+ // or change its role. Now changing the role is not possible yet, but arguably
+ // both clicked and accepted/rejected/etc. should be emitted "atomically"
+ // depending on whatever role the button had at the time of the click.
+ const QDialogButtonBox::ButtonRole buttonRole = q->buttonRole(button);
+ QPointer<QDialogButtonBox> guard(q);
+
emit q->clicked(button);
- switch (q->buttonRole(button)) {
+ if (!guard)
+ return;
+
+ switch (buttonRole) {
case QPlatformDialogHelper::AcceptRole:
case QPlatformDialogHelper::YesRole:
emit q->accepted();