summaryrefslogtreecommitdiffstats
path: root/webservice.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-03-02 14:08:57 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-03-02 14:09:53 -0800
commit950436eba96551552978fc89de2d6968ed7b9bd8 (patch)
tree0a80d51197dc8ba3757799b4cdc03871f82fc013 /webservice.c
parent0ddc77ed9de0e1ee5cbff21771678db8be67d205 (diff)
downloadsubsurface-950436eba96551552978fc89de2d6968ed7b9bd8.tar.gz
Don't duplicate gpsfixes if downloading them multiple times
Simply clear out the table (and free the "dives" that were created). Reported-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'webservice.c')
-rw-r--r--webservice.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/webservice.c b/webservice.c
index 2c8eea80e..be3e1d273 100644
--- a/webservice.c
+++ b/webservice.c
@@ -140,6 +140,14 @@ static void download_dialog_release_xml(struct download_dialog_state *state)
free((void *)state->xmldata);
}
+static void clear_table(struct dive_table *table)
+{
+ int i;
+ for (i = 0; i < table->nr; i++)
+ free(table->dives[i]);
+ table->nr = 0;
+}
+
static void download_dialog_response_cb(GtkDialog *d, gint response, gpointer data)
{
struct download_dialog_state *state = (struct download_dialog_state *)data;
@@ -150,6 +158,7 @@ static void download_dialog_response_cb(GtkDialog *d, gint response, gpointer da
break;
case GTK_RESPONSE_ACCEPT:
/* apply download */
+ clear_table(&gps_location_table);
parse_xml_buffer(_("Webservice"), state->xmldata, state->xmldata_len, &gps_location_table, NULL);
/* now merge the data in the gps_location table into the dive_table */
if (merge_locations_into_dives()) {