aboutsummaryrefslogtreecommitdiffstats
path: root/gtk-gui.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-26 20:37:57 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-26 20:39:51 -0700
commit49fbccd61a30fd2652c1566bfe4b11556120b0d3 (patch)
tree9bed54863ed148203c4f673761a3b405aab8756e /gtk-gui.c
parent85925afe43ff14fe44b919dbd2bc5f4570d105a0 (diff)
downloadsubsurface-49fbccd61a30fd2652c1566bfe4b11556120b0d3.tar.gz
Much improved handling of out of memory errors in the Uemis downloader
Instead of trying to figure out in the GUI code whether to call the downloader again, the logic was moved into the downloader itself. It now attempts to deal cleverly with running out of space on the dive computer filesystem - and in return is able to process the maximum number of dives (instead of just ten or so at a time). Even on partial reads before a failure we are able to collect the data that was completely transferred and report those dives. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r--gtk-gui.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/gtk-gui.c b/gtk-gui.c
index 8704771c7..864ad66d8 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -1415,30 +1415,18 @@ void import_files(GtkWidget *w, gpointer data)
static GError *setup_uemis_import(device_data_t *data)
{
GError *error = NULL;
+ char *buf;
- for (;;) {
- char *buf;
- error = uemis_download(data->devname, &uemis_max_dive_data, &buf, &data->progress);
- if (buf && strlen(buf) > 1) {
+ error = uemis_download(data->devname, &uemis_max_dive_data, &buf, &data->progress);
+ if (buf && strlen(buf) > 1) {
#ifdef DEBUGFILE
- fprintf(debugfile, "xml buffer \"%s\"\n\n", buf);
+ fprintf(debugfile, "xml buffer \"%s\"\n\n", buf);
#endif
- parse_xml_buffer("Uemis Download", buf, strlen(buf), &error);
- set_uemis_last_dive(uemis_max_dive_data);
+ parse_xml_buffer("Uemis Download", buf, strlen(buf), &error);
+ set_uemis_last_dive(uemis_max_dive_data);
#if UEMIS_DEBUG
- fprintf(debugfile, "%s\n", uemis_max_dive_data);
+ fprintf(debugfile, "uemis_max_dive_data: %s\n", uemis_max_dive_data);
#endif
- /* this function is set up to download all the remaining dives
- * yet this can fail in odd ways if we run out of ANS files on
- * the dive computer (basically, its file system is only 6MB and
- * no more than 2MB can be used for communication responses).
- * So in order to avoid this issue we break out here as well,
- * but once we understand how to reset the Uemis Zurich from
- * software the following break statement should be removed */
- break;
- } else {
- break;
- }
}
return error;
}
@@ -1538,6 +1526,8 @@ repeat:
report_dives(TRUE);
break;
default:
+ /* it's possible that some dives were downloaded */
+ report_dives(TRUE);
break;
}
gtk_widget_destroy(dialog);