Re: order of GSignal callbacks



On Sat, Oct 06, 2001 at 11:35:54AM +0200, Tim Janik wrote:
> On Fri, 5 Oct 2001 vishnu pobox com wrote:
> > Is there an easy way to write an assertion about the order of
> > callbacks?  For example, i have:
> > 
> > g_signal_connect (instance, "set-span", G_CALLBACK (cb1), mydata);
> > 
> > // and somewhere else in my code
> > g_signal_connect (instance, "set-span", G_CALLBACK (cb2), mydata);
> > 
> > i'm already using all of the signal execution stages (before, during,
> > after) for ordering.  i'm asking about checking ordering within a stage.
> 
> could you say what/how exactly you're using the different stages for?
> i'm not quite sure what you mean here, since we essentially have
> 5 stages:

Five stages?  But don't i have to pick whether a signal uses RUN_FIRST,
RUN_LAST, or RUN_CLEANUP?  Just out of curiosity, it is possible to
use all five stages with the same signal?

> > Something like:
> > 
> > g_assert (g_signal_handler_order_by_func
> >                (instance, "set-span", 0 /*detail*/, cb1, cb2) < 0);
> 
> erm, what would g_signal_handler_order_by_func() do exactly, compare
> the order of two callbacks given?

Yah :-)

> i don't see much point in supplying such a thing (or, what would be
> required at the basic layer to get this going, a function that assigns
> a numerical id to a closure that relates to its call-order).
> 
> the signal system however makes the guarantee, that, if you connect
> two handlers like this:
> 
> signal_connect (foo);
> signal_connect (bar);
> 
> bar will be executed after foo. i.e. within a stage, handlers are
> called during an emission in the order they got connected.

Oh, OK.  If that's a guarantee then i guess i can code to it.

If i have problems then the easy work-around is to re-emit the
signals from a different instances.  For example, change

  instance1 -> sig1 -> instance2, instance3

into:

  instance1 -> sig1 -> instance2 -> sig2 -> instance3

This would definitely work without any tweaking.

-- 
Victory to the Divine Mother!!
  http://sahajayoga.org




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