Mercurial > touhou
changeset 301:6f1ca1cb5238
Avoid segfaults in the unlikely case a huge number of sprites is rendered.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Sat, 10 Mar 2012 20:30:55 +0100 |
parents | da53bc29b94a |
children | 34ea45d95489 |
files | pytouhou/ui/renderer.pyx |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/pytouhou/ui/renderer.pyx +++ b/pytouhou/ui/renderer.pyx @@ -24,7 +24,7 @@ from .sprite cimport get_sprite_renderin from .texture cimport TextureManager -MAX_ELEMENTS = 10000 +MAX_ELEMENTS = 640*4*3 cdef class Renderer: @@ -47,6 +47,9 @@ cdef class Renderer: indices_by_texture = {} for element in elements: + if nb_vertices >= MAX_ELEMENTS - 4: + break + sprite = element._sprite if sprite and sprite.visible: ox, oy = element.x, element.y