changeset 537:63440d1e0717

Fix a segfault happening at exit time on Windows.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 19 Apr 2014 19:03:38 +0200
parents 6b76c9ba3975
children 1abb6f7db8cc
files pytouhou/ui/opengl/renderer.pxd pytouhou/ui/opengl/renderer.pyx
diffstat 2 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/ui/opengl/renderer.pxd
+++ b/pytouhou/ui/opengl/renderer.pxd
@@ -18,6 +18,9 @@ cdef class Texture:
     cdef GLuint texture, *pointer
     cdef unsigned short indices[2][65536]
 
+    #XXX: keep a reference so that when __dealloc__ is called self.pointer is still valid.
+    cdef Renderer renderer
+
 
 cdef class Renderer:
     cdef TextureManager texture_manager
--- a/pytouhou/ui/opengl/renderer.pyx
+++ b/pytouhou/ui/opengl/renderer.pyx
@@ -61,6 +61,9 @@ cdef class Texture:
         for i in xrange(2):
             renderer.indices[key][i] = self.indices[i]
 
+        #XXX: keep a reference so that when __dealloc__ is called self.pointer is still valid.
+        self.renderer = renderer
+
     def __dealloc__(self):
         if self.texture:
             glDeleteTextures(1, &self.texture)