Commits

Anonymous committed 45e4756

Fixed accidentally releasing the display surface.

  • Participants
  • Parent commits 801d5f7
  • Branches pgreloaded

Comments (0)

Files changed (4)

 * Add prebuilt package for Win32 VC++ builds.
 * Refine quitting for SDL_QuitSubSystem wrapper.
 * Rewrite RST generator to support aliased imports correctly.
+* Check display surface tracking for multiple calls to set_mode using
+  different return variables.
 
 Things to ADD:
 ==============
     PySurface   pysurface;
     
     SDL_Surface *surface;
+    int         isdisplay : 1;
+
     PyObject    *dict;
     PyObject    *weakrefs;
     PyObject    *locklist;

src/sdl/surface.c

     if (self->weakrefs)
         PyObject_ClearWeakRefs ((PyObject *) self);
 
-    if (self->surface)
+    if (self->surface && !self->isdisplay)
         SDL_FreeSurface (self->surface);
+    self->surface = NULL;
 
     obj = (PyObject*) &(self->pysurface);
     obj->ob_type->tp_free ((PyObject*)self);
     surface->dict = NULL;
     surface->weakrefs = NULL;
     surface->intlocks = 0;
+    surface->isdisplay = 0;
 
     surface->pysurface.get_width = _surface_getwidth;
     surface->pysurface.get_height = _surface_getheight;

src/sdl/videomod.c

     /* Not necessary usually. SDL_SetVideoMode() seems to do that
      * implicitly for recent versions of SDL. Though we'll force users
      * to do it explicitly. */
-    ASSERT_VIDEO_INIT(NULL);
+    ASSERT_VIDEO_INIT (NULL);
 
     if (!PyArg_ParseTupleAndKeywords (args, kwds, "ii|il:set_mode", kwlist,
         &width, &height, &bpp, &flags))
         SDL_FreeSurface (surface);
         return NULL;
     }
+    ((PySDLSurface*)sf)->isdisplay = 1;
+
     return sf;
 }