# HG changeset patch # User Sadrul Habib Chowdhury # Date 1242493910 0 # Node ID 7c58f6f50f160e05ebfab72651839cdeac29441c # Parent a8681646a47a5b29fb96251f2e31f8eaa526c914 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? diff -r a8681646a47a -r 7c58f6f50f16 pidgin/gtkimhtml.c --- a/pidgin/gtkimhtml.c Fri May 15 18:00:09 2009 +0000 +++ b/pidgin/gtkimhtml.c Sat May 16 17:11:50 2009 +0000 @@ -5887,13 +5887,25 @@ 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); } }