mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Improve error reporting when exporting a selection of 0 dives.
If no dives are selected when trying to export a selection, a message is shown that no dives were selected, but it's immediately hidden behind a message saying that a temporary file could not be created. In fact, the creation of the temporary file wasn't never attempted, so the message that the user actually sees is misleading. The solution chosen here is to duplicate the check that at least some dives are selected, and abort early if that case is detected, rather than continuing on to show the additional misleading message. Not elegant, but it gets the job done. Better solutions to this include refactoring prepare_dives_for_divelogs to return something more descriptive than a bool, remove that check from prepare_dives_for_divelogs entirely since it doesn't seem to be a good fit there, or switch to exceptions for handling these problems rather than return values. I don't have sufficient familiarity with the codebase to attempt these more invasive changes, but they should be considered in the future. On a final note, some of the other error messages in this file start with a capital letter, but the one relevant to this particular PR does not. Again, I'm not familiar enough with the codebase (or translations) to know if that's safe to change, so I'll leave that for another time or another developer. Reported-by: John Plaxco Signed-off-by: John Plaxco <john@johnplaxco.com>
This commit is contained in:
parent
c38215dfa7
commit
53e31c48ee
1 changed files with 4 additions and 0 deletions
|
@ -484,6 +484,10 @@ void DivelogsDeWebServices::prepareDivesForUpload(bool selected)
|
|||
{
|
||||
/* generate a random filename and create/open that file with zip_open */
|
||||
QString filename = QDir::tempPath() + "/import-" + QString::number(qrand() % 99999999) + ".dld";
|
||||
if (!amount_selected) {
|
||||
report_error(tr("no dives were selected").toUtf8());
|
||||
return;
|
||||
}
|
||||
if (prepare_dives_for_divelogs(filename, selected)) {
|
||||
QFile f(filename);
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
|
|
Loading…
Reference in a new issue