request for g_nullify_pointer and a question about weak refs



Hi,

can we please introduce something like gtk_widget_destroyed() to
GLib or GObject? Despite from being horribly bad named, 
gtk_widget_destroyed() is a very useful function for closures and
destroy_notfiers, but it should definitely live in GLib. I'd
suggest g_nullify_pointer() and I'd vote for marking 
gtk_widget_destroyed() as deprecated once we have a better named
function.


One question about g_object_weak_ref(): How is this supposed to 
work? Imagine you want to create a container that holds weak 
references to its children. Such a container will most probably
have some sort of hash table or list where it stores pointers to
the objects it holds. Now, how is the container supposed to
remove an object from this list when it gets the destroy
notification from the weak reference? At the moment, GWeakNotify
is defined as 

  void (*GWeakNotify) (gpointer data);

The only way to pass the necessary information about the container 
and the object being removed is to create a special struct for this
purpose that holds both pointers. Why isn't GWeakNotify declared 
as

  void (*GWeakNotify) (gpointer object, gpointer data);

or probably
 
  void (*GWeakNotify) (gpointer former_object_do_not_dereference, 
                       gpointer data);

so one can use the data pointer for the container?

Is there something that I missed here or is the current 
implementation of weak references pretty much useless?


Salut, Sven





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