summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dive.h2
-rw-r--r--gtk-gui.c10
-rw-r--r--main.c2
-rw-r--r--parse-xml.c5
4 files changed, 9 insertions, 10 deletions
diff --git a/dive.h b/dive.h
index 746b94093..af141bbde 100644
--- a/dive.h
+++ b/dive.h
@@ -379,7 +379,7 @@ static inline struct dive *get_dive(unsigned int nr)
extern void parse_xml_init(void);
extern void parse_xml_buffer(const char *url, const char *buf, int size, GError **error);
-extern void set_filename(const char *filename);
+extern void set_filename(const char *filename, gboolean force);
extern void parse_file(const char *filename, GError **error);
diff --git a/gtk-gui.c b/gtk-gui.c
index 1d5fc4cc9..6666f5560 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -233,7 +233,7 @@ static void file_save_as(GtkWidget *w, gpointer data)
if (filename){
save_dives(filename);
- set_filename(filename);
+ set_filename(filename, TRUE);
g_free(filename);
mark_divelist_changed(FALSE);
}
@@ -1419,11 +1419,11 @@ void update_progressbar_text(progressbar_t *progress, const char *text)
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(progress->bar), text);
}
-void set_filename(const char *filename)
+void set_filename(const char *filename, gboolean force)
{
- if (existing_filename)
- free(existing_filename);
- existing_filename = NULL;
+ if (!force && existing_filename)
+ return;
+ free(existing_filename);
if (filename)
existing_filename = strdup(filename);
}
diff --git a/main.c b/main.c
index a2c24ec99..01306b1bf 100644
--- a/main.c
+++ b/main.c
@@ -243,7 +243,7 @@ int main(int argc, char **argv)
parse_file(filename, &error);
/* don't report errors - this file may not exist, but make
sure we remember this as the filename in use */
- set_filename(filename);
+ set_filename(filename, FALSE);
}
report_dives(imported);
diff --git a/parse-xml.c b/parse-xml.c
index 1c4db7d9d..a4ae81b25 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -1475,9 +1475,8 @@ void parse_xml_buffer(const char *url, const char *buffer, int size, GError **er
}
return;
}
- /* we assume that the last (or only) filename passed as argument is a
- * great filename to use as default when saving the dives */
- set_filename(url);
+ /* remember, if necessary, that this is the filename to store to */
+ set_filename(url, FALSE);
reset_all();
dive_start();
#ifdef XSLT