Re: getting instance pointer in weak ref notify



Tim Janik <timj gtk org> writes:

> typedef void (*GWeakNotify) (GObject *object, gpointer data);

That gets my vote.

> typedef void (*GWeakNotify) (gpointer data);
> 
> and in gobject.c:
> 
> static void invoke_weak_ref (GObject *o, GWeakNotify wnotify, gpointer data)
> {
>   typedef void (*RealWekRef) (gpointer data, GObject *o_pointer);
>   RealWekRef func = (RealWekRef) wnotify;
>   
>   func (data, o);
> }
> 
> then in the docs we can make a note that people who really need it can
> use void my_func (gpointer data, gpointer obj); as weak-ref callback
> signature, but that isn't recommended because there's not much they
> could do with the object, apart from e.g. using its adress as hash-index
> or the like.

Ugh.

At some point you have to trust the docs, and let people shoot
themselves in the foot.  There is enough that's confusing in GTK+.
Here's a vote to not do it this way.

Thanks,
-Jonathan




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