[Commits] [SCM] claws branch, master, updated. 3.9.3-188-g0816935

colin at claws-mail.org colin at claws-mail.org
Wed May 14 10:34:54 CEST 2014


The branch master of project "claws" (Claws Mail) has been updated
       via  0816935a36966455f7f8a5298a0b8e2604c656af (commit)
      from  87a01636eb14ac2220a3e3b2c9e3e3d24ad4450f (commit)


- Log -----------------------------------------------------------------
commit 0816935a36966455f7f8a5298a0b8e2604c656af
Author: Colin Leroy <colin at colino.net>
Date:   Wed May 14 10:34:41 2014 +0200

    Fix un/registering hooks at each message parse.

diff --git a/src/procheader.c b/src/procheader.c
index 40f0260..fd9cb68 100644
--- a/src/procheader.c
+++ b/src/procheader.c
@@ -485,6 +485,8 @@ static gboolean avatar_from_some_face(gpointer source, gpointer userdata)
 	return FALSE;
 }
 
+static guint avatar_hook_id = 0;
+
 static MsgInfo *parse_stream(void *data, gboolean isstring, MsgFlags flags,
 			     gboolean full, gboolean decrypted)
 {
@@ -495,7 +497,6 @@ static MsgInfo *parse_stream(void *data, gboolean isstring, MsgFlags flags,
 	HeaderEntry *hentry;
 	gint hnum;
 	void *orig_data = data;
-	guint hook_id = -1;
 
 	get_one_field_func get_one_field =
 		isstring ? (get_one_field_func)string_get_one_field
@@ -533,8 +534,11 @@ static MsgInfo *parse_stream(void *data, gboolean isstring, MsgFlags flags,
 	
 	msginfo->inreplyto = NULL;
 
-	if (prefs_common.enable_avatars | AVATARS_ENABLE_CAPTURE) {
-		hook_id = hooks_register_hook(AVATAR_HEADER_UPDATE_HOOKLIST, avatar_from_some_face, NULL);
+	if (avatar_hook_id == 0 && (prefs_common.enable_avatars | AVATARS_ENABLE_CAPTURE)) {
+		avatar_hook_id = hooks_register_hook(AVATAR_HEADER_UPDATE_HOOKLIST, avatar_from_some_face, NULL);
+	} else if (avatar_hook_id != 0 && !(prefs_common.enable_avatars | AVATARS_ENABLE_CAPTURE)) {
+		hooks_unregister_hook(AVATAR_HEADER_UPDATE_HOOKLIST, avatar_hook_id);
+		avatar_hook_id = 0;
 	}
 
 	while ((hnum = get_one_field(buf, sizeof(buf), data, hentry))
@@ -775,10 +779,6 @@ static MsgInfo *parse_stream(void *data, gboolean isstring, MsgFlags flags,
 		msginfo->inreplyto =
 			g_strdup((gchar *)msginfo->references->data);
 
-	if (hook_id != -1) {
-		hooks_unregister_hook(AVATAR_HEADER_UPDATE_HOOKLIST, hook_id);
-	}
-
 	return msginfo;
 }
 

-----------------------------------------------------------------------

Summary of changes:
 src/procheader.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list