Commit e50ed822 authored by Ragnar Thomsen's avatar Ragnar Thomsen
Browse files

Use QPointer for openArchive dialog

Using a QPointer prevents the application from crashing if the main
application quits somehow while the dialog is open.

See:
https://blogs.kde.org/node/3919
parent 3875bdb8
......@@ -220,10 +220,10 @@ void MainWindow::openArchive()
Q_ASSERT(iface);
Q_UNUSED(iface);
QFileDialog dlg(this, i18nc("to open an archive", "Open Archive"));
dlg.setMimeTypeFilters(Kerfuffle::supportedMimeTypes());
QPointer<QFileDialog> dlg = new QFileDialog(this, i18nc("to open an archive", "Open Archive"));
dlg->setMimeTypeFilters(Kerfuffle::supportedMimeTypes());
QStringList filters = dlg.nameFilters();
QStringList filters = dlg->nameFilters();
filters.removeDuplicates();
filters.sort(Qt::CaseInsensitive);
......@@ -239,13 +239,14 @@ void MainWindow::openArchive()
}
}
filters.prepend(allArchives + QLatin1Char(')'));
dlg.setNameFilters(filters);
dlg->setNameFilters(filters);
dlg.setFileMode(QFileDialog::ExistingFile);
dlg.setAcceptMode(QFileDialog::AcceptOpen);
if (dlg.exec() == QDialog::Accepted) {
openUrl(dlg.selectedUrls().first());
dlg->setFileMode(QFileDialog::ExistingFile);
dlg->setAcceptMode(QFileDialog::AcceptOpen);
if (dlg->exec() == QDialog::Accepted) {
openUrl(dlg->selectedUrls().first());
}
delete dlg;
}
void MainWindow::openUrl(const QUrl& url)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment