pidgin: 2f365712: Block/Unblock the signal handler when if..

sadrul at pidgin.im sadrul at pidgin.im
Sat May 16 13:10:40 EDT 2009


-----------------------------------------------------------------
Revision: 2f3657123ac0390c8a5d94dcb1920e22fd59af29
Ancestor: 31464c7b8f119c22d5dd37addac3ba83b6df0de2
Author: sadrul at pidgin.im
Date: 2009-05-16T17:11:50
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/2f3657123ac0390c8a5d94dcb1920e22fd59af29

Modified files:
        pidgin/gtkimhtml.c

ChangeLog: 

Block/Unblock the signal handler when if it's unblocked/blocked.

Trying to unblock the handler when it has not been blocked yet causes a
'handler not blocked' error message. When this message is added in the
debug window, it goes into a mutex-lock from this line:

	gtk_list_store_append(debug_win->store, &iter);

I have noticed this before on some occasions, where pidgin goes into a
freeze when doing something from a signal-handler causes a debug message
to be printed. Anyone knows why?


-------------- next part --------------
============================================================
--- pidgin/gtkimhtml.c	64a940a6ccd2ee245f8f624d3267c06cbec3f014
+++ pidgin/gtkimhtml.c	7529dc464d14362dce427d2c7dfe2c0997a51800
@@ -5887,13 +5887,25 @@ void gtk_imhtml_set_populate_primary_cli
 
 void gtk_imhtml_set_populate_primary_clipboard(GtkIMHtml *imhtml, gboolean populate)
 {
+	gulong signal_id;
+	signal_id = g_signal_handler_find(imhtml->text_buffer,
+			G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_UNBLOCKED, 0, 0, NULL,
+			mark_set_so_update_selection_cb, NULL);
 	if (populate) {
-		g_signal_handlers_unblock_matched(imhtml->text_buffer,
-				G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
-				mark_set_so_update_selection_cb, NULL);
+		if (!signal_id) {
+			/* We didn't find an unblocked signal handler, which means there
+			   is a blocked handler. Now unblock it.
+			   This is necessary to avoid a mutex-lock when the debug message
+			   saying 'no handler is blocked' is printed in the debug window.
+				-- sad
+			 */
+			g_signal_handlers_unblock_matched(imhtml->text_buffer,
+					G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
+					mark_set_so_update_selection_cb, NULL);
+		}
 	} else {
-		g_signal_handlers_block_matched(imhtml->text_buffer,
-				G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
-				mark_set_so_update_selection_cb, NULL);
+		/* Block only if we found an unblocked handler */
+		if (signal_id)
+			g_signal_handler_block(imhtml->text_buffer, signal_id);
 	}
 }


More information about the Commits mailing list