[Commits] [SCM] claws branch, master, updated. 3.12.0-87-g2c781ca

mones at claws-mail.org mones at claws-mail.org
Tue Sep 22 14:57:41 CEST 2015


The branch, master has been updated
       via  2c781ca221d8b1a25d382063c8ff2e84d4f25be6 (commit)
      from  f54e21bebac3b16c6fbcb149d65fc89da7558ab8 (commit)

Summary of changes:
 src/plugins/libravatar/libravatar.c |   28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)


- Log -----------------------------------------------------------------
commit 2c781ca221d8b1a25d382063c8ff2e84d4f25be6
Author: Ricardo Mones <ricardo at mones.org>
Date:   Tue Sep 22 14:57:17 2015 +0200

    Libravatar: remove hooks on failed init

diff --git a/src/plugins/libravatar/libravatar.c b/src/plugins/libravatar/libravatar.c
index f67d583..e36829e 100644
--- a/src/plugins/libravatar/libravatar.c
+++ b/src/plugins/libravatar/libravatar.c
@@ -347,6 +347,20 @@ static void missing_cache_done()
 	}
 }
 
+static void unregister_hooks()
+{
+	if (render_hook_id != -1) {
+		hooks_unregister_hook(AVATAR_IMAGE_RENDER_HOOKLIST,
+				      render_hook_id);
+		render_hook_id = -1;
+	}
+	if (update_hook_id != -1) {
+		hooks_unregister_hook(AVATAR_HEADER_UPDATE_HOOKLIST,
+				      update_hook_id);
+		update_hook_id = -1;
+	}
+}
+
 /**
  * Initialize plugin.
  *
@@ -372,11 +386,13 @@ gint plugin_init(gchar **error)
 					     libravatar_image_render_hook,
 					     NULL);
 	if (render_hook_id == -1) {
+		unregister_hooks();
 		*error = g_strdup(_("Failed to register avatar image render hook"));
 		return -1;
 	}
 	/* cache dir */
 	if (cache_dir_init() == -1) {
+		unregister_hooks();
 		*error = g_strdup(_("Failed to create avatar image cache directory"));
 		return -1;
 	}
@@ -386,6 +402,7 @@ gint plugin_init(gchar **error)
 	curl_global_init(CURL_GLOBAL_DEFAULT);
 	/* missing cache */
 	if (missing_cache_init() == -1) {
+		unregister_hooks();
 		*error = g_strdup(_("Failed to load missing items cache"));
 		return -1;
 	}
@@ -402,16 +419,7 @@ gint plugin_init(gchar **error)
  */
 gboolean plugin_done(void)
 {
-	if (render_hook_id != -1) {
-		hooks_unregister_hook(AVATAR_IMAGE_RENDER_HOOKLIST,
-				      render_hook_id);
-		render_hook_id = -1;
-	}
-	if (update_hook_id != -1) {
-		hooks_unregister_hook(AVATAR_HEADER_UPDATE_HOOKLIST,
-				      update_hook_id);
-		update_hook_id = -1;
-	}
+	unregister_hooks();
 	libravatar_prefs_done();
 	missing_cache_done();
 	if (cache_dir != NULL)

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list