Re: #50089 - g_signal_handler_disconnect_matched too hard



On 26 Mar 2001, Owen Taylor wrote:

> Index: gsignal.h
> ===================================================================
> RCS file: /cvs/gnome/glib/gobject/gsignal.h,v
> retrieving revision 1.16
> diff -u -r1.16 gsignal.h
> --- gsignal.h	2001/03/09 21:39:51	1.16
> +++ gsignal.h	2001/03/26 21:29:48
> @@ -216,6 +216,26 @@
>  
>  
>  /* --- convenience --- */
> +
> +#define	g_signal_handlers_disconnect_by_func(o,f,d)                                        \

what does this function need the "_by_" for?

> +    g_signal_handlers_disconnect_matched ((o), G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,  \
> +					  0, 0, NULL, (f), (d))
> +#define	g_signal_handlers_disconnect_by_data(o,d)                                          \

disconnect_by_data is a _very_ bad idea and needs to be deprecated for
gtk as well.
the reason being that the data items are anonymous, so neither the caller
nor the signal system can guess what disconnect_by_data was really meant to
do.
so setups like:

user code:
g_object_connect (obj,
                  "signal:foo", my_func, GUINT_TO_POINTER (1),
                  TRUE);
e.g. gnome-libs code:
g_object_connect (obj,
                  "signal:foo", gnome_func, GUINT_TO_POINTER (TRUE),
                  TRUE);

will break with disconnect_by_data.
yes, cases where the functions data is an allocated structure
are less likely to break, but still they preserve bad pitfalls
and we're currently only getting away because of small likelyness
for this broken case.

> +    g_signal_handlers_disconnect_matched ((o), G_SIGNAL_MATCH_DATA,                        \
> +					  0, 0, NULL, 0, (d))
> +#define	g_signal_handlers_block_by_func(o,f,d)                                             \

don't see a need for "_by_", you want to block a function, right?

> +    g_signal_handlers_block_matched      ((o), G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,  \
> +                                          0, 0, NULL, (f), (d))
> +#define	g_signal_handlers_block_by_data(o,d)                                               \

the very same as for disconnect_by_data applies here.

> +    g_signal_handlers_block_matched      ((o), G_SIGNAL_MATCH_DATA,                        \
> +					  0, 0, NULL, 0, (d))
> +#define	g_signal_handlers_unblock_by_func(o,f,d)                                           \
> +    g_signal_handlers_unblock_matched    ((o), G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,  \
> +                		          0, 0, NULL, (f), (d))
> +#define	g_signal_handlers_unblock_by_data(o,d)                                             \

and here.

> +    g_signal_handlers_unblock_matched    ((o), G_SIGNAL_MATCH_DATA,                        \
> +					  0, 0, NULL, 0, (d))
> +
>  #define g_signal_connectc(instance, detailed_signal, c_handler, data, swapped) \
>      g_signal_connect_data ((instance), (detailed_signal), (c_handler), (data), NULL, (swapped), FALSE)

---
ciaoTJ





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]