Re: GtkBuilder Public API - Last call



Hi,

Perhaps gtk_builder_connect_signals_with_data (or something like that)
is the way to go. At least in a case we plan to include the DestroyNotify.
Otherwise we could tolerate one extra parameter into connect_signals, right?

Putting a DestroyNotify there will create the following (easy) bug scenario:

  data = g_new(...);
  ...
  gtk_builder_connect_signals_with_data(builder, data, g_free);

and now the memory is freed once per signal connected... Of course this is a 
programmers mistake (no proper refcounting), but I think it would 
be good to place a warning into the documentation? 

-Markku-

Lainaus Johan Dahlin <jdahlin async com br>:

> > Of course one can use connect_full variant to achieve this, but that
> > also means that GModule-related code needs to be written into app.
> 
> Exactly, I think this use case is valid to avoid duplicating that code.
> 
> I see two possible solutions;
> 
> 1) Change gtk_builder_connect_signals () to accept a gpointer to the
>    user data
> 2) Add a new method  which is similar to gtk_builder_connect_signals but
>    accepts user_data and perhaps a GDestroyNotify.
> 
> Any preference? I'm leaning towards the latter.
> 
> -- 
> Johan Dahlin <jdahlin async com br>
> Async Open Source
> 



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