Re: Slow spin button signal get doubled



Hi,

On Tue, Sep 8, 2009 at 9:15 PM, Taneli Kalvas <taneli v m kalvas jyu fi> wrote:
> I guess I have found a bug: I am encountering strange behaviour from spin
> button. If the callback of a spin button "value-changed" signal is slow
> enough, the callback will be called twice when the spin button is adjusted
> for the first time. Further actions work normally. This behaviour only
> happens when operating the spin button with mouse. By using keyboard up or
> down arrows, the spin button only takes one step as it should.

When operating with the mouse, the spin button installs a timeout for
the "spinning behavior", which is that the value continues to increase
or decrease as long as the mouse button is pressed.  The "spinning" is
of course stopped as soon as the mouse button is released.  In your
case, the problem with the delay in the callback is that the
button-release signal is processed much later than the mouse button is
actually released.  (The value-changed signal handler is called from
the button-press handler, so before the button-released handler).
Because of this, the "spin" timeout gets a chance to fire.

This does not fully explain why this behavior is only seen in the
first time.  But, I have seen this behavior a few times after the
first time as well.

In general it is advisable to not do any extensive processing in a
signal callback.  I would suggest to look into changing your code such
that the extensive processing is done outside the signal handler, in a
timeout or idle handler.


regards,

-kris.


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