Re: Signal memory leak.



> No, it actually must be a GtkObject because it will be cast to one
> on the call.
> 
>                 /* don't cast with GTK_OBJECT () */
>                 (* signal->marshaller) ((GtkObject*) handlers->func_data,
>                                         handlers->func,
>                                         object,
>                                         params);

In C (and in C++ w/o MI), you can just pass and cast
pointers w/o their values being changed, even if the cast
is fully invalid.  For example:

static void print_string(const char* string)
{
	g_message("%s", string);
}

...

gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
                          GTK_SIGNAL_FUNC(print_string),
			  (GtkObject*) "hello, joe");


This works, and has the advantage that "print_string" isn't specialized
for a particular signal type.

> I guess I just don't understand why there was such a distinction.  
> gtk_connect_object seems dangerous and outdated.  While alive
> would seem that the more appropriate behavior. 

Both behaviors are desirable and fashionable :),
IMHO the function's name is the problem.
It should be `gtk_object_connect_swapped' or `gtk_object_connect_other'
and take a gpointer.



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