scijava / ui-behaviour

Configurable input handling, via mapped behaviours
Other
4 stars 2 forks source link

double scroll events #5

Closed funkey closed 8 years ago

funkey commented 8 years ago

In rare cases, the ScrollBehaviour gets into a state where it emits two scroll events for every mouse wheel event. Unfortunately, this is difficult to reproduce. If it happens, it happens right from the start of the application and stays like that.

Observed in TranslateZController.

tpietzsch commented 8 years ago

Hmm... Could you try to get it to happen in a debugger, and then see what happens in https://github.com/scijava/ui-behaviour/blob/master/src/main/java/org/scijava/ui/behaviour/MouseAndKeyHandler.java#L317-L345 ?

funkey commented 8 years ago

Sure, of course.

I found that all scroll BehaviourEntrys appeared twice in the list scrolls when it happens. I suspect that in updateInternalMaps() a scrolls.clear(); is missing.

However, I wonder why it happens only sometimes. updateInternalMaps() is only called from update(), which is synchronized. So in some cases, between two calls to update(), the modification counts change. Not so surprising, since update() is triggered by AWT Events, and they come asynchronously and depend on what the user is doing with the mouse/keyboard during the initialization.

tpietzsch commented 8 years ago

Yes, awesome! That's it, good catch.

Your explanation is right, I think. It depends on whether update() is called already before the input/behaviourMaps have "settled".

I'll fix it and release a new version.

tpietzsch commented 8 years ago

I released ui-behaviour 1,0.5. Thanks again for finding this @funkey

funkey commented 8 years ago

You're welcome, and thanks for the quick fix!