Re: (*prepare) and (*check) need user_data




Tim Janik <timj@gtk.org> writes:

> On 27 Mar 1999, Owen Taylor wrote:
> 
> > This is slightly bizarre, to me. 
> > 
> > Bite the bullet, create a structure, put your GPollFD 
> > pointer into it, and pass it as the gsource and get it over
> > with.
> 
> sure, i would have done that if there had been no user_data in the first place,
> but since we do provide a user_data pointer with GSources, there's simply no
> point in not passing that along in the appropriate callbacks.
> the old way would have made me create a structure
> struct {
>  gpointer source_data;
>  GPollFD* user_data;
>  GDestroyNotifier user_data_destroy;
> };
> just to get access to this from (*check) and (*prepare), eventhough user_data
> was designed to cover exactly this need. that appeared too ironic to me, to
> not fix it.

Ummm, no, it made you create a struct:

  struct {
    SomeObject *the_interesting_thing;
    GPollFD *pollfd;
  }
 
which probably would make things a bit clearer to the person
reading your code then your current hack.

But anyways... this isn't a big deal. It doesn't actively
hurt anything to have the user_data pointer in there, as
long as we document the fact that you should not dispatch
callbacks in those functions, despite it's presence.

It's just ugly.

                                        Owen



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