Re: Re-setting the callback function from within ... the callback function?



On Mon, 30 Apr 2001, Chris Quinn wrote:

> as tends to happen so often, after submitting a bug report I found that gtk_emit_stop_by_name did the trick. gtk_signal_emit_stop had not worked for me so I presumed the former would not either. Unfortunately I was labouring under the impression gtk_signal_connect returned an id suitable for input to gtk_signal_emit_stop, which it is not.
> 
> My problem is solved but it seems to have prompted a source level solution. But at what cost? I'd hate to be responsible for slowing down GTK by a few cycles for every signal (multiplied by depth of its propagation) for what amounts to a very esoteric problem that turned out to have a simple (and natural) solution!


signal_emit_stop, even if use correctly (with a signal id, not a handler id) is
definitely the wrong aproach, as it will also stop other signal handlers, not
just your own from being invoked during the current emission.
for 1.2.10 (CVS HEAD for 1.3 already contains the change you deisred) the
correct solution (provided you can't make your handler ignore the
nextmost invokation throguh a global variable or somesuch) is to:
a) re-connect your signal handler
b) block the just connected signal handler
c) connect an unblocking signal handler that de-installs itself

the signal handler from c) will unblock the signal handler connected in a)
and then disconnect itself, that way, upon the current emission, the
re-connected handler will first be ignored (because you blocked it in b))
and then get unblocked (so its ready to be called upon the _next_ 
signal emission) from the handler in c) which also disconnects itself.

i hope this helps to get the desired behaviour for the 1.2.x versions of
gtk. note that this workaround does not correctly work with CVS HEAD,
there, the invokation of the handler in a) is prevented for the next-most emission
of the signal, not the current one.

> 
> Cheers,
> Chris
> 

---
ciaoTJ





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