aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/divelogexportdialog.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-02-06 22:18:42 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-02-09 12:13:18 -0800
commit5b302235f4a7c3a5c8bf1bc6404171ebef1b321c (patch)
tree176f6bbcd91f85e156769e88b0af312da28e37d1 /desktop-widgets/divelogexportdialog.cpp
parent2cea115ddb7528d9e6dd1bf918ebf5c670b82479 (diff)
downloadsubsurface-5b302235f4a7c3a5c8bf1bc6404171ebef1b321c.tar.gz
Cleanup: Remove global QFuture from exportFuncs
When exporting dives we show a message. The message is closed when the export is finished. This is coordinated by a QFuture. Instead of keeping a global QFuture in the export-code, pass it around as a local variable. This is supported according to Qt's documentation: "QFuture is a lightweight reference counted class that can be passed by value." and the source code indicates the same. Not only does this remove a global, it also makes the code more flexible: Now we could show one notification per export, for example. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/divelogexportdialog.cpp')
-rw-r--r--desktop-widgets/divelogexportdialog.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/desktop-widgets/divelogexportdialog.cpp b/desktop-widgets/divelogexportdialog.cpp
index dc0928e8f..0e85bc6bd 100644
--- a/desktop-widgets/divelogexportdialog.cpp
+++ b/desktop-widgets/divelogexportdialog.cpp
@@ -214,9 +214,10 @@ void DiveLogExportDialog::on_buttonBox_accepted()
qPrefDisplay::set_lastDir(fileInfo.dir().path());
// the non XSLT exports are called directly above, the XSLT based ons are called here
if (!stylesheet.isEmpty()) {
- exportFuncs::instance()->exportUsingStyleSheet(filename, ui->exportSelected->isChecked(), ui->CSVUnits_2->currentIndex(), stylesheet.toUtf8(), ui->anonymize->isChecked());
- MainWindow::instance()->getNotificationWidget()->showNotification(tr("Please wait, exporting..."), KMessageWidget::Information);
- MainWindow::instance()->getNotificationWidget()->setFuture(exportFuncs::instance()->future);
+ QFuture<void> future = exportFuncs::instance()->exportUsingStyleSheet(filename, ui->exportSelected->isChecked(),
+ ui->CSVUnits_2->currentIndex(), stylesheet.toUtf8(), ui->anonymize->isChecked());
+ MainWindow::instance()->getNotificationWidget()->showNotification(tr("Please wait, exporting..."), KMessageWidget::Information);
+ MainWindow::instance()->getNotificationWidget()->setFuture(future);
}
}
}