Cleanup: don't produce no-dives error message in libdivecomputer.c

If no dives were downloaded in do_libdivecomputer_import(), an
error message would be produced. To check for downloaded dives,
the function would access the global downloadTable instead of
the actual table the dives are imported to (at the moment the
same - but the interface allows for a different table).

Move the error-creation to the caller to avoid this situation.
An alternative option would be to check the actual table the
dives were supposed to be downloaded to. But from a program-logic
point of view "no dives" does not seem like an error condition.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-10-04 18:34:30 +02:00 committed by Dirk Hohndel
parent 8a18396104
commit 420aab9454
2 changed files with 2 additions and 2 deletions

View file

@ -91,6 +91,8 @@ void DownloadThread::run()
error = str_error(errorText, internalData->devname, internalData->vendor, internalData->product);
qDebug() << "Finishing download thread:" << error;
} else {
if (!downloadTable.nr)
error = tr("No new dives downloaded from dive computer");
qDebug() << "Finishing download thread:" << downloadTable.nr << "dives downloaded";
}
qPrefDiveComputer::set_vendor(internalData->vendor);

View file

@ -1422,8 +1422,6 @@ const char *do_libdivecomputer_import(device_data_t *data)
data->device = NULL;
dc_iostream_close(data->iostream);
data->iostream = NULL;
if (!downloadTable.nr)
dev_info(data, translate("gettextFromC", "No new dives downloaded from dive computer"));
}
dc_context_free(data->context);