Re: weak_pointer_location parameter to g_object_add_weak_pointer



Darin Adler <darin bentspoon com> writes:

> The weak_pointer_location parameter to g_object_add_weak_pointer and
> g_object_remove_weak_pointer is gpointer *, but it should really be
> gpointer, or else anyone who uses this has to use a cast unless they store
> the pointer in a gpointer rather than a GtkWidget * or whatever. I seem to
> recall some discussion of this in the past.
> 
> Is it too late to fix this? Note that relaxing the parameter type to
> gpointer would be unlikely to break any code, unless it involved a pointer
> to the g_object_add_weak_pointer function itself.

This was discussed at some length:

  http://mail.gnome.org/archives/gtk-devel-list/2001-August/msg00433.html

And followups. I agree that the gpointer * is a little annoying, but my
argument was that it better that way:

 - Silently accepting a 'GObject *' will lead to people making the
   mistake of passing in the object rather than the location of the
   object, either inadvertently, or due to misunderstandings of how
   pointers work in C.

 - I don't like tossing out the information that what is needed is the
   location of a pointer to an object, rather than the pointer to the
   object.

And I still hold to this. I'd also still have preferred GObject **, but...

Regards,
                                        Owen



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