Stefan Kost wrote: > hi, > > I have an interface, where I share some data between the instances. > the data is created on first access. Now I also would like to release > it when the last instance goes. > > problem 1: base_finalize() is not called for static types > > I thought that I could do some own ref-counting and then do > g_object_weak_ref on the instances to decrement the ref-count. > > problem 2: There is nothing in the GTypeInfo for an iface that is > called for each new instance (using instance_init causes > g_type_register_static (G_TYPE_INTERFACE,...) to fail as one does not > really instantiate the iface, but the type that implements it). > > Any ideas?
I don't think this method will work -- I'm pretty sure GTypes (esp static types) never get destroyed, even after their last instance is destroyed. Probably your best bet would be to create your shared data in the instance_init function on first run (just make it a static global var in the file), and then refcount it. When your last instance is destroyed, the refcount of the shared data drops to zero and you can destroy it. -brian _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list