Mercurial > pidgin.yaz
comparison pidgin/gtkimhtml.c @ 26961:7c58f6f50f16
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?
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sat, 16 May 2009 17:11:50 +0000 |
parents | 3c06cd0e1717 |
children | 8c1816137194 |
comparison
equal
deleted
inserted
replaced
26960:a8681646a47a | 26961:7c58f6f50f16 |
---|---|
5885 G_CALLBACK(return_add_newline_cb), NULL); | 5885 G_CALLBACK(return_add_newline_cb), NULL); |
5886 } | 5886 } |
5887 | 5887 |
5888 void gtk_imhtml_set_populate_primary_clipboard(GtkIMHtml *imhtml, gboolean populate) | 5888 void gtk_imhtml_set_populate_primary_clipboard(GtkIMHtml *imhtml, gboolean populate) |
5889 { | 5889 { |
5890 gulong signal_id; | |
5891 signal_id = g_signal_handler_find(imhtml->text_buffer, | |
5892 G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_UNBLOCKED, 0, 0, NULL, | |
5893 mark_set_so_update_selection_cb, NULL); | |
5890 if (populate) { | 5894 if (populate) { |
5891 g_signal_handlers_unblock_matched(imhtml->text_buffer, | 5895 if (!signal_id) { |
5892 G_SIGNAL_MATCH_FUNC, 0, 0, NULL, | 5896 /* We didn't find an unblocked signal handler, which means there |
5893 mark_set_so_update_selection_cb, NULL); | 5897 is a blocked handler. Now unblock it. |
5898 This is necessary to avoid a mutex-lock when the debug message | |
5899 saying 'no handler is blocked' is printed in the debug window. | |
5900 -- sad | |
5901 */ | |
5902 g_signal_handlers_unblock_matched(imhtml->text_buffer, | |
5903 G_SIGNAL_MATCH_FUNC, 0, 0, NULL, | |
5904 mark_set_so_update_selection_cb, NULL); | |
5905 } | |
5894 } else { | 5906 } else { |
5895 g_signal_handlers_block_matched(imhtml->text_buffer, | 5907 /* Block only if we found an unblocked handler */ |
5896 G_SIGNAL_MATCH_FUNC, 0, 0, NULL, | 5908 if (signal_id) |
5897 mark_set_so_update_selection_cb, NULL); | 5909 g_signal_handler_block(imhtml->text_buffer, signal_id); |
5898 } | 5910 } |
5899 } | 5911 } |