1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

[Fix] Allocating AcceptLanguage dialog on heap. Should close #156

- crash when accepting Preferences
This commit is contained in:
nowrep 2012-01-13 22:11:01 +01:00
parent 6cdb61990d
commit 2c9837eaef
2 changed files with 11 additions and 6 deletions

View File

@ -127,8 +127,8 @@ QStringList AcceptLanguage::expand(const QLocale::Language &language)
void AcceptLanguage::addLanguage() void AcceptLanguage::addLanguage()
{ {
Ui_AddAcceptLanguage _ui = Ui_AddAcceptLanguage(); Ui_AddAcceptLanguage _ui = Ui_AddAcceptLanguage();
QDialog dialog(this); QDialog* dialog = new QDialog(this);
_ui.setupUi(&dialog); _ui.setupUi(dialog);
QStringList allLanguages; QStringList allLanguages;
for (int i = 1 + (int)QLocale::C; i <= (int)QLocale::LastLanguage; ++i) { for (int i = 1 + (int)QLocale::C; i <= (int)QLocale::LastLanguage; ++i) {
@ -137,9 +137,10 @@ void AcceptLanguage::addLanguage()
_ui.listWidget->addItems(allLanguages); _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; return;
} }
@ -150,12 +151,14 @@ void AcceptLanguage::addLanguage()
else { else {
QListWidgetItem* c = _ui.listWidget->currentItem(); QListWidgetItem* c = _ui.listWidget->currentItem();
if (!c) { if (!c) {
delete dialog;
return; return;
} }
ui->listWidget->addItem(c->text()); ui->listWidget->addItem(c->text());
} }
delete dialog;
} }
void AcceptLanguage::removeLanguage() void AcceptLanguage::removeLanguage()

View File

@ -524,8 +524,10 @@ void Preferences::openSslManager()
void Preferences::showAcceptLanguage() void Preferences::showAcceptLanguage()
{ {
AcceptLanguage a(this); AcceptLanguage* a = new AcceptLanguage(this);
a.exec(); a->exec();
delete a;
} }
void Preferences::cacheValueChanged(int value) void Preferences::cacheValueChanged(int value)