diff --git a/gobject/gsignal.c b/gobject/gsignal.c index bf3e9c66e..4bd918406 100644 --- a/gobject/gsignal.c +++ b/gobject/gsignal.c @@ -2951,11 +2951,14 @@ signal_handlers_foreach_matched_unlocked_R (gpointer instance, * the criteria values are passed as arguments. A handler must match on all * flags set in @mask to be blocked (i.e. the match is conjunctive). * - * Passing at least one of the %G_SIGNAL_MATCH_CLOSURE, %G_SIGNAL_MATCH_FUNC + * Passing at least one of the %G_SIGNAL_MATCH_ID, %G_SIGNAL_MATCH_CLOSURE, + * %G_SIGNAL_MATCH_FUNC * or %G_SIGNAL_MATCH_DATA match flags is required for successful matches. * If no handlers were found, 0 is returned, the number of blocked handlers * otherwise. * + * Support for %G_SIGNAL_MATCH_ID was added in GLib 2.78. + * * Returns: The number of handlers that matched. */ guint @@ -2972,7 +2975,7 @@ g_signal_handlers_block_matched (gpointer instance, g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), 0); g_return_val_if_fail ((mask & ~G_SIGNAL_MATCH_MASK) == 0, 0); - if (mask & (G_SIGNAL_MATCH_CLOSURE | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)) + if (mask & (G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_CLOSURE | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)) { SIGNAL_LOCK (); n_handlers = @@ -3003,12 +3006,15 @@ g_signal_handlers_block_matched (gpointer instance, * the criteria values are passed as arguments. A handler must match on all * flags set in @mask to be unblocked (i.e. the match is conjunctive). * - * Passing at least one of the %G_SIGNAL_MATCH_CLOSURE, %G_SIGNAL_MATCH_FUNC + * Passing at least one of the %G_SIGNAL_MATCH_ID, %G_SIGNAL_MATCH_CLOSURE, + * %G_SIGNAL_MATCH_FUNC * or %G_SIGNAL_MATCH_DATA match flags is required for successful matches. * If no handlers were found, 0 is returned, the number of unblocked handlers * otherwise. The match criteria should not apply to any handlers that are * not currently blocked. * + * Support for %G_SIGNAL_MATCH_ID was added in GLib 2.78. + * * Returns: The number of handlers that matched. */ guint @@ -3025,7 +3031,7 @@ g_signal_handlers_unblock_matched (gpointer instance, g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), 0); g_return_val_if_fail ((mask & ~G_SIGNAL_MATCH_MASK) == 0, 0); - if (mask & (G_SIGNAL_MATCH_CLOSURE | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)) + if (mask & (G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_CLOSURE | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)) { SIGNAL_LOCK (); n_handlers = @@ -3056,11 +3062,14 @@ g_signal_handlers_unblock_matched (gpointer instance, * the criteria values are passed as arguments. A handler must match on all * flags set in @mask to be disconnected (i.e. the match is conjunctive). * - * Passing at least one of the %G_SIGNAL_MATCH_CLOSURE, %G_SIGNAL_MATCH_FUNC or + * Passing at least one of the %G_SIGNAL_MATCH_ID, %G_SIGNAL_MATCH_CLOSURE, + * %G_SIGNAL_MATCH_FUNC or * %G_SIGNAL_MATCH_DATA match flags is required for successful * matches. If no handlers were found, 0 is returned, the number of * disconnected handlers otherwise. * + * Support for %G_SIGNAL_MATCH_ID was added in GLib 2.78. + * * Returns: The number of handlers that matched. */ guint @@ -3077,7 +3086,7 @@ g_signal_handlers_disconnect_matched (gpointer instance, g_return_val_if_fail (G_TYPE_CHECK_INSTANCE (instance), 0); g_return_val_if_fail ((mask & ~G_SIGNAL_MATCH_MASK) == 0, 0); - if (mask & (G_SIGNAL_MATCH_CLOSURE | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)) + if (mask & (G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_CLOSURE | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA)) { SIGNAL_LOCK (); n_handlers = diff --git a/gobject/tests/signals.c b/gobject/tests/signals.c index bc0306082..b8bd8247e 100644 --- a/gobject/tests/signals.c +++ b/gobject/tests/signals.c @@ -1487,6 +1487,17 @@ test_block_handler (void) g_signal_handlers_unblock_matched (test2, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, test_handler, NULL); + /* Test match by signal ID. */ + g_assert_cmpuint (g_signal_handlers_block_matched (test1, G_SIGNAL_MATCH_ID, simple_id, 0, NULL, NULL, NULL), ==, 1); + + g_signal_emit_by_name (test1, "simple"); + g_signal_emit_by_name (test2, "simple"); + + g_assert_cmpint (count1, ==, 3); + g_assert_cmpint (count2, ==, 4); + + g_assert_cmpuint (g_signal_handlers_unblock_matched (test1, G_SIGNAL_MATCH_ID, simple_id, 0, NULL, NULL, NULL), ==, 1); + /* Match types are conjunctive */ g_assert_cmpuint (g_signal_handlers_block_matched (test1, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, test_handler, "will not match"), ==, 0); g_assert_cmpuint (g_signal_handlers_block_matched (test1, G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, 0, 0, NULL, test_handler, &count1), ==, 1);