[gmime] Always clear the header cache when setting headers



commit 6ce14b702fc9e61385d600b337aeef832a6dbc69
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Wed Jun 13 10:23:31 2012 -0400

    Always clear the header cache when setting headers
    
    2012-06-13  Jeffrey Stedfast  <fejj gnome org>
    
    	* gmime/gmime-message.c: When setting a header, make sure to
    	always clear the header list cache of the toplevel mime_part as
    	well.

 ChangeLog             |    6 ++++++
 gmime/gmime-message.c |   26 ++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fa8c461..f7b8cd9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2012-06-13  Jeffrey Stedfast  <fejj gnome org>
 
+	* gmime/gmime-message.c: When setting a header, make sure to
+	always clear the header list cache of the toplevel mime_part as
+	well.
+
+2012-06-13  Jeffrey Stedfast  <fejj gnome org>
+
 	* gmime/gmime-param.c (rfc2184_param_new): Only decode the charset
 	and lang if the parameter is actually encoded. Thanks to Peter
 	Bloomfield for this patch.
diff --git a/gmime/gmime-message.c b/gmime/gmime-message.c
index 6f9022a..eae671e 100644
--- a/gmime/gmime-message.c
+++ b/gmime/gmime-message.c
@@ -1085,6 +1085,9 @@ g_mime_message_set_sender (GMimeMessage *message, const char *sender)
 		g_mime_header_list_set (GMIME_OBJECT (message)->headers, "From", "");
 		message->from = NULL;
 	}
+	
+	if (message->mime_part)
+		g_mime_header_list_set_stream (message->mime_part->headers, NULL);
 }
 
 
@@ -1122,6 +1125,9 @@ g_mime_message_set_reply_to (GMimeMessage *message, const char *reply_to)
 	message->reply_to = g_mime_strdup_trim (reply_to);
 	
 	g_mime_header_list_set (GMIME_OBJECT (message)->headers, "Reply-To", message->reply_to);
+	
+	if (message->mime_part)
+		g_mime_header_list_set_stream (message->mime_part->headers, NULL);
 }
 
 
@@ -1159,6 +1165,9 @@ sync_recipient_header (GMimeMessage *message, GMimeRecipientType type)
 		/* list should never be NULL... */
 		g_mime_header_list_set (object->headers, name, NULL);
 	}
+	
+	if (message->mime_part)
+		g_mime_header_list_set_stream (message->mime_part->headers, NULL);
 }
 
 static void
@@ -1203,6 +1212,11 @@ g_mime_message_add_recipient (GMimeMessage *message, GMimeRecipientType type, co
 	ia = internet_address_mailbox_new (name, addr);
 	internet_address_list_add (recipients, ia);
 	g_object_unref (ia);
+	
+	if (message->mime_part)
+		g_mime_header_list_set_stream (message->mime_part->headers, NULL);
+	
+	g_mime_header_list_set_stream (((GMimeObject *) message)->headers, NULL);
 }
 
 
@@ -1280,6 +1294,9 @@ g_mime_message_set_subject (GMimeMessage *message, const char *subject)
 	encoded = g_mime_utils_header_encode_text (message->subject);
 	g_mime_object_set_header (GMIME_OBJECT (message), "Subject", encoded);
 	g_free (encoded);
+	
+	if (message->mime_part)
+		g_mime_header_list_set_stream (message->mime_part->headers, NULL);
 }
 
 
@@ -1321,6 +1338,9 @@ g_mime_message_set_date (GMimeMessage *message, time_t date, int tz_offset)
 	str = g_mime_utils_header_format_date (date, tz_offset);
 	g_mime_object_set_header (GMIME_OBJECT (message), "Date", str);
 	g_free (str);
+	
+	if (message->mime_part)
+		g_mime_header_list_set_stream (message->mime_part->headers, NULL);
 }
 
 
@@ -1387,6 +1407,9 @@ g_mime_message_set_date_as_string (GMimeMessage *message, const char *str)
 	buf = g_mime_utils_header_format_date (date, tz_offset);
 	g_mime_object_set_header (GMIME_OBJECT (message), "Date", buf);
 	g_free (buf);
+	
+	if (message->mime_part)
+		g_mime_header_list_set_stream (message->mime_part->headers, NULL);
 }
 
 
@@ -1411,6 +1434,9 @@ g_mime_message_set_message_id (GMimeMessage *message, const char *message_id)
 	msgid = g_strdup_printf ("<%s>", message_id);
 	g_mime_object_set_header (GMIME_OBJECT (message), "Message-Id", msgid);
 	g_free (msgid);
+	
+	if (message->mime_part)
+		g_mime_header_list_set_stream (message->mime_part->headers, NULL);
 }
 
 



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