[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [konsole] src: Use QPointer for KeyBindingEditor dialog
From:       Kurt Hindenburg <kurt.hindenburg () gmail ! com>
Date:       2016-09-04 22:46:54
Message-ID: E1bggBi-0001Oy-LJ () code ! kde ! org
[Download RAW message or body]

Git commit 4f15c586019027d87a06645a12844aceaa8ffd94 by Kurt Hindenburg.
Committed on 04/09/2016 at 22:45.
Pushed by hindenburg into branch 'master'.

Use QPointer for KeyBindingEditor dialog

Add QPointer guard around dialog exec()

M  +9    -8    src/EditProfileDialog.cpp

http://commits.kde.org/konsole/4f15c586019027d87a06645a12844aceaa8ffd94

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()
 {
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic