summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-10-01 18:12:59 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-04 10:22:11 +0200
commit5a787305612c18ee9a442e4dd6067d3c35f05f87 (patch)
treec3456b3c5eb99131480d6a227ac71f4f591c81be
parent3f51849dc3582d34683c111e5fd3a53f414ab1c2 (diff)
downloadsubsurface-5a787305612c18ee9a442e4dd6067d3c35f05f87.tar.gz
Import: Make DiveLogImportDialog modal
By making this modal, we can use a local variable and remove the nasty "deleteLater()" hack to reclaim the resources after the dialog closes. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--desktop-widgets/divelogimportdialog.cpp16
-rw-r--r--desktop-widgets/divelogimportdialog.h2
-rw-r--r--desktop-widgets/mainwindow.cpp4
3 files changed, 2 insertions, 20 deletions
diff --git a/desktop-widgets/divelogimportdialog.cpp b/desktop-widgets/divelogimportdialog.cpp
index 61549a7f1..5df477349 100644
--- a/desktop-widgets/divelogimportdialog.cpp
+++ b/desktop-widgets/divelogimportdialog.cpp
@@ -1010,22 +1010,6 @@ void DiveLogImportDialog::on_buttonBox_accepted()
MainWindow::instance()->refreshDisplay();
}
-// Since this is a non-modal dialog, the caller can't delete it at the call-site.
-// Therefore, hook into the accept() and reject() functions and schedule the object
-// for deletion with deleteLater(). Horrible, but absolutely the "Qt-way".
-// TODO: Think about making the dialog modal.
-void DiveLogImportDialog::accept()
-{
- QDialog::accept();
- deleteLater();
-}
-
-void DiveLogImportDialog::reject()
-{
- QDialog::reject();
- deleteLater();
-}
-
TagDragDelegate::TagDragDelegate(QObject *parent) : QStyledItemDelegate(parent)
{
}
diff --git a/desktop-widgets/divelogimportdialog.h b/desktop-widgets/divelogimportdialog.h
index e8ba4b598..d64cbc656 100644
--- a/desktop-widgets/divelogimportdialog.h
+++ b/desktop-widgets/divelogimportdialog.h
@@ -89,8 +89,6 @@ slots:
void loadFileContents(int value, enum whatChanged triggeredBy);
int setup_csv_params(QStringList r, char **params, int pnr);
int parseTxtHeader(QString fileName, char **params, int pnr);
- void accept() override;
- void reject() override;
private:
bool selector;
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index 0ab46fafd..e37c7a7bd 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -1811,8 +1811,8 @@ void MainWindow::on_actionImportDiveLog_triggered()
}
if (csvFiles.size()) {
- DiveLogImportDialog *diveLogImport = new DiveLogImportDialog(csvFiles, this);
- diveLogImport->show();
+ DiveLogImportDialog diveLogImport(csvFiles, this);
+ diveLogImport.exec();
}
}