summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRagnar Thomsen <[email protected]>2015-08-22 23:47:15 +0200
committerRagnar Thomsen <[email protected]>2015-08-22 23:47:15 +0200
commite50ed8222117b0289ae0f66afad5631e6b31f37a (patch)
tree89b74a8e31f109445fc21b744ec70762c716b27b
parent3875bdb8b3ab4f700f20731629d60ce5b8a7cc2e (diff)
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
-rw-r--r--app/mainwindow.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp
index f1b22d4..b98b250 100644
--- a/app/mainwindow.cpp
+++ b/app/mainwindow.cpp
@@ -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)