diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-05-14 20:17:08 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-05-14 12:52:54 -0700 |
commit | 9b4728c7a96edf48f7150bec943fb8484d9332cd (patch) | |
tree | 50b174110da61a1a198afdc7fe969425c4dc95d3 /desktop-widgets | |
parent | 826c01d0a00253727942ae26e876d509a72908b3 (diff) | |
download | subsurface-9b4728c7a96edf48f7150bec943fb8484d9332cd.tar.gz |
Cloud-storage: consistently don't save empty file on desktop version
Make the behavior consistent: Don't save an empty file to the cloud,
neither on selection of "Save to cloud" nor on "Save". The latter
was not the case. It was a bit hard to trigger: Open cloud, delete
all dives, save.
Fixes #1228
Reported-by: Jan Iversen <jani@apache.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets')
-rw-r--r-- | desktop-widgets/mainwindow.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index a4cddd264..9898fc72b 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -610,13 +610,21 @@ void MainWindow::on_actionCloudstorageopen_triggered() refreshDisplay(); } +// Return whether saving to cloud is OK. If it isn't, show an error return false. +static bool saveToCloudOK() +{ + if (!dive_table.nr) { + report_error(qPrintable(QObject::tr("Don't save an empty log to the cloud"))); + return false; + } + return true; +} + void MainWindow::on_actionCloudstoragesave_triggered() { QString filename; - if (!dive_table.nr) { - report_error(qPrintable(tr("Don't save an empty log to the cloud"))); + if (!saveToCloudOK()) return; - } if (getCloudURL(filename)) return; @@ -1725,6 +1733,8 @@ int MainWindow::file_save(void) return file_save_as(); is_cloud = (strncmp(existing_filename, "http", 4) == 0); + if (is_cloud && !saveToCloudOK()) + return -1; if (information()->isEditing()) information()->acceptChanges(); |