summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKurt Hindenburg <kurt.hindenburg@gmail.com>2016-09-04 22:45:22 (GMT)
committerKurt Hindenburg <kurt.hindenburg@gmail.com>2016-09-04 22:45:22 (GMT)
commit4f15c586019027d87a06645a12844aceaa8ffd94 (patch)
treedc459711a0186803499c3fe6bfd0f015a9ffd768
parentedcb028d299c4dcf152116e05f4adfb0c35198bd (diff)
Use QPointer for KeyBindingEditor dialog
Add QPointer guard around dialog exec()
-rw-r--r--src/EditProfileDialog.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp
index ec3216a..b7d4e6c 100644
--- a/src/EditProfileDialog.cpp
+++ b/src/EditProfileDialog.cpp
@@ -870,16 +870,16 @@ void EditProfileDialog::showKeyBindingEditor(bool isNewTranslator)
Q_ASSERT(translator);
- QDialog dialog(this);
- QDialogButtonBox *buttonBox = new QDialogButtonBox(&dialog);
+ QPointer<QDialog> dialog = new QDialog(this);
+ QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
- connect(buttonBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
- connect(buttonBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
+ connect(buttonBox, &QDialogButtonBox::accepted, dialog, &QDialog::accept);
+ connect(buttonBox, &QDialogButtonBox::rejected, dialog, &QDialog::reject);
if (isNewTranslator)
- dialog.setWindowTitle(i18n("New Key Binding List"));
+ dialog->setWindowTitle(i18n("New Key Binding List"));
else
- dialog.setWindowTitle(i18n("Edit Key Binding List"));
+ dialog->setWindowTitle(i18n("Edit Key Binding List"));
KeyBindingEditor* editor = new KeyBindingEditor;
@@ -892,9 +892,9 @@ void EditProfileDialog::showKeyBindingEditor(bool isNewTranslator)
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(editor);
layout->addWidget(buttonBox);
- dialog.setLayout(layout);
+ dialog->setLayout(layout);
- if (dialog.exec() == QDialog::Accepted) {
+ if (dialog->exec() == QDialog::Accepted) {
KeyboardTranslator* newTranslator = new KeyboardTranslator(*editor->translator());
if (isNewTranslator)
@@ -911,6 +911,7 @@ void EditProfileDialog::showKeyBindingEditor(bool isNewTranslator)
updateTempProfileProperty(Profile::KeyBindings, newTranslator->name());
}
}
+ delete dialog;
}
void EditProfileDialog::newKeyBinding()
{