a GList of g_object_add_weak_pointer()s



I am in the midst of fitfully trying to convert netperf4 (http://www.netperf.org/svn/netperf4/trunk/ to use GObject. In netperf4 there are these things (soon to be objects) called "tests" and a test can be dependent upon another test. Several tests can depend on a given test. I figured that a GList (into glib for a penny, in for a pound I figure) of g_object_add_weak_pointer() references would then allow the test on which the other N tests are dependent to send each of them a signal via a "foreach" when it was setup and they could proceede.

The problem is that g_list_append() wants a pointer value, but g_object_add_weak_pointer() wants a place to stuff the pointer - the GList node won't really exist until g_list_append() completes, which leaves me a chicken and egg situation. I suppose I could just pass g_list_appeand() NULL, but (yes, I should look at the source or write a test program :) would g_list_append() actually like that?

I don't really want to allocate another bit of memory to hold the reference, I'd like to have it in the data field of the GList node.

Suggestions?

I was thinking that I could have a dummy area that I pass to g_list_append(), and then I could pass &(node->data) to g_object_add_weak_pointer().

Does that sound reasonable?

rick jones
for those who want to see some really bad GObject coding :) http://www.netperf.org/svn/netperf4/branches/netperf4_gobject

FWIW I'm working off the online API reference and Matthias Warkus's "The Official GNOME 2 Developer's Guide" (there is to be GTK=2.0 in netperf4's future, which is what triggered the desire to GObjectify netperf4...)



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