From 2c9837eaef07e1b92f3e06b72d15147e5c496665 Mon Sep 17 00:00:00 2001 From: nowrep Date: Fri, 13 Jan 2012 22:11:01 +0100 Subject: [PATCH] [Fix] Allocating AcceptLanguage dialog on heap. Should close #156 - crash when accepting Preferences --- src/preferences/acceptlanguage.cpp | 11 +++++++---- src/preferences/preferences.cpp | 6 ++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/preferences/acceptlanguage.cpp b/src/preferences/acceptlanguage.cpp index 40e6932d7..10a47ef90 100644 --- a/src/preferences/acceptlanguage.cpp +++ b/src/preferences/acceptlanguage.cpp @@ -127,8 +127,8 @@ QStringList AcceptLanguage::expand(const QLocale::Language &language) void AcceptLanguage::addLanguage() { Ui_AddAcceptLanguage _ui = Ui_AddAcceptLanguage(); - QDialog dialog(this); - _ui.setupUi(&dialog); + QDialog* dialog = new QDialog(this); + _ui.setupUi(dialog); QStringList allLanguages; for (int i = 1 + (int)QLocale::C; i <= (int)QLocale::LastLanguage; ++i) { @@ -137,9 +137,10 @@ void AcceptLanguage::addLanguage() _ui.listWidget->addItems(allLanguages); - connect(_ui.listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), &dialog, SLOT(accept())); + connect(_ui.listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), dialog, SLOT(accept())); - if (dialog.exec() == QDialog::Rejected) { + if (dialog->exec() == QDialog::Rejected) { + delete dialog; return; } @@ -150,12 +151,14 @@ void AcceptLanguage::addLanguage() else { QListWidgetItem* c = _ui.listWidget->currentItem(); if (!c) { + delete dialog; return; } ui->listWidget->addItem(c->text()); } + delete dialog; } void AcceptLanguage::removeLanguage() diff --git a/src/preferences/preferences.cpp b/src/preferences/preferences.cpp index 78973118d..b68224e0c 100644 --- a/src/preferences/preferences.cpp +++ b/src/preferences/preferences.cpp @@ -524,8 +524,10 @@ void Preferences::openSslManager() void Preferences::showAcceptLanguage() { - AcceptLanguage a(this); - a.exec(); + AcceptLanguage* a = new AcceptLanguage(this); + a->exec(); + + delete a; } void Preferences::cacheValueChanged(int value)