From 393c87af52df8cfbb62d7ce884990819dae8d208 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Wed, 4 Aug 1999 18:37:50 +0000 Subject: BUGFIX #1819 Please note that the calendar_save routine is now responsible for changing the filename attribute of the calendar struct, rather than the calling function. This was so that the filename could be reverted if the open failed. svn path=/trunk/; revision=1080 --- calendar/calendar.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'calendar/calendar.c') diff --git a/calendar/calendar.c b/calendar/calendar.c index 339995cb92..dfeb1d6cc8 100644 --- a/calendar/calendar.c +++ b/calendar/calendar.c @@ -12,6 +12,8 @@ * */ +#include +#include #include #include #include @@ -396,8 +398,11 @@ void calendar_save (Calendar *cal, char *fname) { VObject *vcal; + FILE *fp; + GtkWidget *dlg; struct stat s; - + int status; + if (fname == NULL) fname = cal->filename; @@ -412,11 +417,23 @@ calendar_save (Calendar *cal, char *fname) g_free (backup_name); } - writeVObjectToFile (fname, vcal); + fp = fopen(fname,"w"); + if (fp) { + writeVObject(fp, vcal); + fclose(fp); + if (strcmp(cal->filename, fname)) { + if (cal->filename) + g_free (cal->filename); + cal->filename = g_strdup (fname); + } + status = stat (fname, &s); + cal->file_time = s.st_mtime; + } else { + dlg = gnome_message_box_new(_("Failed to save calendar!"), + GNOME_MESSAGE_BOX_ERROR, "Ok", NULL); + gtk_widget_show(dlg); + } - stat (fname, &s); - cal->file_time = s.st_mtime; - cleanVObject (vcal); cleanStrTbl (); } -- cgit v1.2.3