Repository: kivy/kivy

Issue:
Scatter crash on windows
I just tested BETA-1 with showcase, and when i tried to move the cat:

```
running "python.exe C:\Users\tito\Desktop\Kivy-1.9.0-dev-py3.3-win32\kivy\exampl
es\demo\showcase\main.py" \n
[INFO              ] [Logger      ] Record log in C:\Users\tito\.kivy\logs\kivy_
14-09-21_2.txt
[INFO              ] Kivy v1.9.0-dev
[INFO              ] [Python      ] v3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21
:18:40) [MSC v.1600 32 bit (Intel)]
[INFO              ] [Factory     ] 170 symbols loaded
[INFO              ] [Image       ] Providers: img_tex, img_dds, img_pygame, img
_gif (img_sdl2, img_ffpyplayer, img_pil ignored)
[INFO              ] [Window      ] Provider: pygame(['window_egl_rpi'] ignored)

OpenGL Warning: WGL_SAMPLE_BUFFERS_EXT & WGL_SAMPLES_EXT not supporteed!
OpenGL Warning: WGL_SAMPLE_BUFFERS_EXT & WGL_SAMPLES_EXT not supporteed!
GLEW initialization succeeded
GL: glGenFramebuffers is NULL, try to detect an extension
GL: available extensions: GL_EXT_texture_compression_s3tc GL_EXT_draw_range_elem
ents GL_EXT_framebuffer_object GL_EXT_compiled_vertex_array GL_ARB_depth_texture
 GL_ARB_fragment_program GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion
_query GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_shadow GL_ARB_texture_
border_clamp GL_ARB_texture_compression GL_ARB_texture_cube_map GL_ARB_texture_e
nv_add GL_ARB_texture_env_combine GL_EXT_texture_env_combine GL_ARB_texture_env_
crossbar GL_ARB_texture_env_dot3 GL_EXT_texture_env_dot3 GL_ARB_texture_mirrored
_repeat GL_IBM_texture_mirrored_repeat GL_ATI_texture_mirror_once GL_ARB_texture
_non_power_of_two GL_ARB_transpose_matrix GL_ARB_vertex_buffer_object GL_ARB_pix
el_buffer_object GL_ARB_vertex_program GL_ARB_window_pos GL_EXT_blend_color GL_E
XT_blend_minmax GL_EXT_blend_func_separate GL_EXT_blend_subtract GL_EXT_texture_
env_add GL_EXT_fog_coord GL_EXT_multi_draw_arrays GL_EXT_secondary_color GL_EXT_
shadow_funcs GL_EXT_stencil_wrap GL_EXT_texture_cube_map GL_EXT_texture_edge_cla
mp GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod_bias GL_EXT_texture_obje
ct GL_EXT_texture3D GL_IBM_rasterpos_clip GL_NV_fog_distance GL_NV_fragment_prog
ram GL_NV_fragment_program_option GL_NV_fragment_program2 GL_NV_register_combine
rs GL_NV_register_combiners2 GL_NV_texgen_reflection GL_NV_texture_rectangle GL_
ARB_texture_rectangle GL_NV_vertex_program GL_NV_vertex_program1_1 GL_NV_vertex_
program2 GL_NV_vertex_program2_option GL_NV_vertex_program3 GL_SGIS_generate_mip
map GL_ARB_shading_language_100 GL_ARB_shader_objects GL_ARB_vertex_shader GL_AR
B_fragment_shader GL_EXT_texture_sRGB GL_EXT_framebuffer_blit GL_EXT_blend_equat
ion_separate GL_EXT_stencil_two_side GL_CR_state_parameter GL_CR_cursor_position
 GL_CR_bounding_box GL_CR_print_string GL_CR_tilesort_info GL_CR_synchronization
 GL_CR_head_spu_name GL_CR_performance_info GL_CR_window_size GL_CR_tile_info GL
_CR_saveframe GL_CR_readback_barrier_size GL_CR_server_id_sharing GL_CR_server_m
atrix
GL: EXT_framebuffer_object is supported
[INFO              ] [GL          ] OpenGL version <b'2.1 Chromium 1.9'>
[INFO              ] [GL          ] OpenGL vendor <b'Humper'>
[INFO              ] [GL          ] OpenGL renderer <b'Chromium'>
[INFO              ] [GL          ] OpenGL parsed version: 2, 1
[INFO              ] [GL          ] Shading version <b'4.40 NVIDIA via Cg compil
er'>
[INFO              ] [GL          ] Texture max size <16384>
[INFO              ] [GL          ] Texture max units <32>
[INFO              ] [Window      ] virtual keyboard not allowed, single mode, n
ot docked
[INFO              ] [Text        ] Provider: pygame(['text_sdl2'] ignored)
[INFO              ] [GL          ] NPOT texture support is available
[INFO              ] [OSC         ] using <thread> for socket
[INFO              ] [Base        ] Start application main loop
[WARNING           ] [Accordion   ] not enough space for displaying all children

[WARNING           ] [Accordion   ] need 132px, got 100px
[WARNING           ] [Accordion   ] layout aborted.
[WARNING           ] [Accordion   ] not enough space for displaying all children

[WARNING           ] [Accordion   ] need 132px, got 84px
[WARNING           ] [Accordion   ] layout aborted.
[WARNING           ] [Accordion   ] not enough space for displaying all children

[WARNING           ] [Accordion   ] need 132px, got 84px
[WARNING           ] [Accordion   ] layout aborted.
[ERROR             ] unable to access to <\pagefile.sys>
Traceback (most recent call last):
  File "C:\Users\tito\Desktop\Kivy-1.9.0-dev-py3.3-win32\kivy\kivy\uix\filechoos
er.py", line 122, in is_hidden
    return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
pywintypes.error: (32, 'GetFileAttributesEx', 'Le processus ne peut pas accéder
au fichier car ce fichier est utilisé par un autre processus.')
[ERROR             ] unable to access to <\pagefile.sys>
Traceback (most recent call last):
  File "C:\Users\tito\Desktop\Kivy-1.9.0-dev-py3.3-win32\kivy\kivy\uix\filechoos
er.py", line 122, in is_hidden
    return GetFileAttributesExW(fn)[0] & FILE_ATTRIBUTE_HIDDEN
pywintypes.error: (32, 'GetFileAttributesEx', 'Le processus ne peut pas accéder
au fichier car ce fichier est utilisé par un autre processus.')
[INFO              ] [VideoGstplayer] Using Gstreamer 1.2.1.0
[INFO              ] [Video       ] Provider: gstplayer
[INFO              ] [Base        ] Leaving application in progress...
 Traceback (most recent call last):
   File "C:\Users\tito\Desktop\Kivy-1.9.0-dev-py3.3-win32\kivy\examples\demo\sho
wcase\main.py", line 212, in <module>
     ShowcaseApp().run()
   File "C:\Users\tito\Desktop\Kivy-1.9.0-dev-py3.3-win32\kivy\kivy\app.py", lin
e 825, in run
     runTouchApp()
   File "C:\Users\tito\Desktop\Kivy-1.9.0-dev-py3.3-win32\kivy\kivy\base.py", li
ne 484, in runTouchApp
     EventLoop.window.mainloop()
   File "C:\Users\tito\Desktop\Kivy-1.9.0-dev-py3.3-win32\kivy\kivy\core\window\
window_pygame.py", line 364, in mainloop
     self._mainloop()
   File "C:\Users\tito\Desktop\Kivy-1.9.0-dev-py3.3-win32\kivy\kivy\core\window\
window_pygame.py", line 268, in _mainloop
     EventLoop.idle()
   File "C:\Users\tito\Desktop\Kivy-1.9.0-dev-py3.3-win32\kivy\kivy\base.py", li
ne 327, in idle
     self.dispatch_input()
   File "C:\Users\tito\Desktop\Kivy-1.9.0-dev-py3.3-win32\kivy\kivy\base.py", li
ne 312, in dispatch_input
     post_dispatch_input(*pop(0))
   File "C:\Users\tito\Desktop\Kivy-1.9.0-dev-py3.3-win32\kivy\kivy\base.py", li
ne 271, in post_dispatch_input
     wid.dispatch('on_touch_move', me)
   File "_event.pyx", line 392, in kivy._event.EventDispatcher.dispatch (kivy\_e
vent.c:4602)
   File "C:\Users\tito\Desktop\Kivy-1.9.0-dev-py3.3-win32\kivy\kivy\uix\scatter.
py", line 547, in on_touch_move
     if self.transform_with_touch(touch):
   File "C:\Users\tito\Desktop\Kivy-1.9.0-dev-py3.3-win32\kivy\kivy\uix\scatter.
py", line 452, in transform_with_touch
     anchor = max(points[:-1], key=lambda p: p.distance(touch.pos))
 ValueError: max() arg is an empty sequence
Appuyez sur une touche pour continuer...
```



Discussion:
Same with Python 2.7

It just crash within the showcase, not within the pictures demo.

Same crash on osx

Same crash on a Raspberry Pi running Raspbian Linux, Python 2.7.

seems the touch ends up two times in self._touches, i so transform_with_touches is called when it shouldn't.

Seems to be because scrollview calls simulate_touch_down in on_scroll_start, which is called a second time from on_scroll_move.

Bug can be reproduced by wrapping the root FloatLayout into a ScrollView with do_scroll_x and do_scroll_y to False.


Resolving patch:
diff --git a/kivy/uix/scrollview.py b/kivy/uix/scrollview.py
--- a/kivy/uix/scrollview.py
+++ b/kivy/uix/scrollview.py
@@ -669,6 +669,9 @@ def on_touch_move(self, touch):
         if touch.grab_current is not self:
             return True
 
+        if not (self.do_scroll_y or self.do_scroll_x):
+            return super(ScrollView, self).on_touch_move(touch)
+
         touch.ud['sv.handled'] = {'x': False, 'y': False}
         if self.dispatch('on_scroll_move', touch):
             return True


Test patch: