Commit fc483788 authored by Adam Barth's avatar Adam Barth

Merge pull request #372 from abarth/fix_sporadic_crash

Sporadic crash from invalid touch event
parents 456e17d0 3c14e41b
...@@ -102,27 +102,23 @@ class SkyBinding { ...@@ -102,27 +102,23 @@ class SkyBinding {
return state; return state;
} }
PointerState _getOrCreateStateForPointer(event, position) {
PointerState state = _stateForPointer[event.pointer];
if (state == null)
state = _createStateForPointer(event, position);
return state;
}
void _handlePointerEvent(sky.PointerEvent event) { void _handlePointerEvent(sky.PointerEvent event) {
Point position = new Point(event.x, event.y); Point position = new Point(event.x, event.y);
PointerState state; PointerState state = _getOrCreateStateForPointer(event, position);
switch(event.type) {
case 'pointerdown': if (event.type == 'pointerup' || event.type == 'pointercancel') {
state = _createStateForPointer(event, position); if (_hammingWeight(event.buttons) <= 1)
break; _stateForPointer.remove(event.pointer);
case 'pointerup':
case 'pointercancel':
state = _stateForPointer[event.pointer];
if (_hammingWeight(event.buttons) <= 1)
_stateForPointer.remove(event.pointer);
break;
case 'pointermove':
state = _stateForPointer[event.pointer];
// In the case of mouse hover we won't already have a cached down.
if (state == null)
state = _createStateForPointer(event, position);
break;
} }
event.dx = position.x - state.lastPosition.x; event.dx = position.x - state.lastPosition.x;
event.dy = position.y - state.lastPosition.y; event.dy = position.y - state.lastPosition.y;
state.lastPosition = position; state.lastPosition = position;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment