[goffice] Make sure the first rather than the last error is shown. Plug leak.



commit ec1cf672a2145fb171bcd5bb66b91a8f2cbbd46c
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Tue Aug 24 11:56:31 2010 -0600

    Make sure the first rather than the last error is shown. Plug leak.
    
    2010-08-24  Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	* goffice/app/go-cmd-context.c (go_cmd_context_error_info_list): new
    	* goffice/app/go-cmd-context.h (go_cmd_context_error_info_list): new
    	* goffice/app/io-context-priv.h (_GOIOContext): change info field into
    	  a GSList
    	* goffice/app/io-context.c (ioc_finalize): free info list
    	(go_io_error_clear): ditto
    	(go_io_error_info_set): append to list
    	(go_io_warning_varargs): ditto
    	(go_io_error_push): add details to the last item
    	(go_io_error_display): call go_cmd_context_error_info_list

 ChangeLog                     |   13 +++++++++++++
 NEWS                          |    4 ++++
 goffice/app/go-cmd-context.c  |   11 +++++++++++
 goffice/app/go-cmd-context.h  |    1 +
 goffice/app/io-context-priv.h |    3 ++-
 goffice/app/io-context.c      |   25 +++++++++++++++++--------
 6 files changed, 48 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f7b254c..3900f36 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2010-08-24  Andreas J. Guelzow <aguelzow pyrshep ca>
+
+	* goffice/app/go-cmd-context.c (go_cmd_context_error_info_list): new
+	* goffice/app/go-cmd-context.h (go_cmd_context_error_info_list): new
+	* goffice/app/io-context-priv.h (_GOIOContext): change info field into
+	  a GSList
+	* goffice/app/io-context.c (ioc_finalize): free info list
+	(go_io_error_clear): ditto
+	(go_io_error_info_set): append to list
+	(go_io_warning_varargs): ditto
+	(go_io_error_push): add details to the last item
+	(go_io_error_display): call go_cmd_context_error_info_list
+
 2010-08-24  Morten Welinder  <terra gnome org>
 
 	* goffice/component/go-component-factory.c: Fix char-xmlChar
diff --git a/NEWS b/NEWS
index 68ad593..741e5ff 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,9 @@
 goffice 0.8.10:
 
+Andreas:
+	* Make sure the first rather than the last error is shown.
+	* Plug leak.
+
 Jean:
 	* Always use real line width when evaluating dashes. [#442546]
 	* Update x and y limits when data change for xyz plots. [#627288]
diff --git a/goffice/app/go-cmd-context.c b/goffice/app/go-cmd-context.c
index 1cc091f..9879487 100644
--- a/goffice/app/go-cmd-context.c
+++ b/goffice/app/go-cmd-context.c
@@ -1,3 +1,4 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*
  * go-cmd-context.c : Error dispatch utilities.
  *
@@ -36,6 +37,16 @@ go_cmd_context_error_info (GOCmdContext *context, GOErrorInfo *stack)
 }
 
 void
+go_cmd_context_error_info_list (GOCmdContext *cc, GSList *stack)
+{
+	g_return_if_fail (GO_IS_CMD_CONTEXT (cc));
+	if (stack == NULL)
+		go_cmd_context_error_info (cc, NULL);
+	else
+		go_cmd_context_error_info (cc, g_slist_last (stack)->data);
+}
+
+void
 go_cmd_context_error_system (GOCmdContext *context, char const *message)
 {
 	GError *err = format_message (go_error_system (), message);
diff --git a/goffice/app/go-cmd-context.h b/goffice/app/go-cmd-context.h
index 07ffa8c..375ca51 100644
--- a/goffice/app/go-cmd-context.h
+++ b/goffice/app/go-cmd-context.h
@@ -43,6 +43,7 @@ void   go_cmd_context_error_export  (GOCmdContext *cc, char const *msg);
 void   go_cmd_context_error_invalid (GOCmdContext *cc,
 				     char const *msg, char const *val);
 void   go_cmd_context_error_info    (GOCmdContext *cc, GOErrorInfo *stack);
+void   go_cmd_context_error_info_list (GOCmdContext *cc, GSList *stack);
 
 /* An initial set of std errors */
 GQuark go_error_system  (void);
diff --git a/goffice/app/io-context-priv.h b/goffice/app/io-context-priv.h
index c38ec36..f6df9e9 100644
--- a/goffice/app/io-context-priv.h
+++ b/goffice/app/io-context-priv.h
@@ -1,3 +1,4 @@
+/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 #ifndef GO_IO_CONTEXT_PRIV_H
 #define GO_IO_CONTEXT_PRIV_H
 
@@ -47,7 +48,7 @@ struct _GOIOContext {
 	GObject base;
 
 	GOCmdContext	*impl;
-	GOErrorInfo	*info;
+	GSList          *info; /* GSList of GOErrorInfo in reverse order */
 	gboolean	 error_occurred;
 	gboolean	 warning_occurred;
 
diff --git a/goffice/app/io-context.c b/goffice/app/io-context.c
index 7c97ce4..4f2a1a0 100644
--- a/goffice/app/io-context.c
+++ b/goffice/app/io-context.c
@@ -57,7 +57,7 @@ ioc_finalize (GObject *obj)
 	g_return_if_fail (GO_IS_IO_CONTEXT (obj));
 
 	ioc = GO_IO_CONTEXT (obj);
-	go_error_info_free (ioc->info);
+	go_slist_free_custom (ioc->info, (GFreeFunc) go_error_info_free);
 	if (ioc->impl) {
 		go_cmd_context_progress_set (ioc->impl, 0.0);
 		go_cmd_context_progress_message_set (ioc->impl, NULL);
@@ -193,7 +193,7 @@ go_io_error_info_set (GOIOContext *context, GOErrorInfo *error)
 
 	g_return_if_fail (context->info == NULL);
 
-	context->info = error;
+	context->info = g_slist_prepend (context->info, error);
 	context->error_occurred = TRUE;
 }
 
@@ -202,9 +202,15 @@ go_io_error_push (GOIOContext *context, GOErrorInfo *error)
 {
 	g_return_if_fail (context != NULL);
 	g_return_if_fail (error != NULL);
-
-	go_error_info_add_details (error, context->info);
-	context->info = error;
+	
+	if (context->info == NULL) {
+		go_error_info_add_details (error, NULL);
+		context->info = g_slist_append (NULL, error);
+	} else {
+		GOErrorInfo *info = context->info->data;
+		go_error_info_add_details (error, info);
+		context->info->data = error;
+	}
 }
 
 void
@@ -219,7 +225,8 @@ go_io_error_display (GOIOContext *context)
 			cc = context->impl;
 		else
 			cc = GO_CMD_CONTEXT (context);
-		go_cmd_context_error_info (cc, context->info);
+		go_cmd_context_error_info_list 
+			(cc, context->info);
 	}
 }
 
@@ -231,7 +238,7 @@ go_io_error_clear (GOIOContext *context)
 
 	context->error_occurred = FALSE;
 	context->warning_occurred = FALSE;
-	go_error_info_free (context->info);
+	go_slist_free_custom (context->info, (GFreeFunc) go_error_info_free);
 	context->info = NULL;
 }
 
@@ -470,7 +477,9 @@ go_io_warning (G_GNUC_UNUSED GOIOContext *context,
 void
 go_io_warning_varargs (GOIOContext *context, char const *fmt, va_list args)
 {
-	context->info = go_error_info_new_vprintf (GO_WARNING, fmt, args);
+	context->info = g_slist_prepend 
+		(context->info, go_error_info_new_vprintf 
+		 (GO_WARNING, fmt, args));
 	context->warning_occurred = TRUE;
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]