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>
This commit is contained in:
Berthold Stoeger 2018-05-14 20:17:08 +02:00 committed by Dirk Hohndel
parent 826c01d0a0
commit 9b4728c7a9

View file

@ -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();