Commits

pygame  committed c87dd74

small safety added do dead display Surfaces after display.quit()

  • Participants
  • Parent commits 4116bd4

Comments (0)

Files changed (4)

 	Dave Wallace, John Popplewell
 - And our dutiful bug hunters:
 	Angus, Guillaume Proux, Frank Raiser,
-	Austin Henry, Kaweh Kazemi, Arturo Aldama
+	Austin Henry, Kaweh Kazemi, Arturo Aldama,
+        Mike Mulcheck
 
 Cheers to TheCorruptor for his incredible work on the pygame logo.
 
 # BREAK = change breaks existing code
 # BUG	= fixed a bug that was (or could have been) crashing
 
+December 2, 2001
+	small protection for display Surfaces after display.quit()
+
 December 1, 2001
 	made time.delay() more accurate
 	created time.wait() to work like old delay()

File src/display.c

 /* init routines */
 static void display_autoquit(void)
 {
-	Py_XDECREF(DisplaySurfaceObject);
-	DisplaySurfaceObject = NULL;
+        if(DisplaySurfaceObject)
+        {
+                /*Ack, this still leaves pretty deadly Surface objs around*/
+		((PySurfaceObject*)DisplaySurfaceObject)->surf = NULL;
+                Py_DECREF(DisplaySurfaceObject);
+        }
 }
 
 static PyObject* display_autoinit(PyObject* self, PyObject* arg)

File src/surface.c

 	SDL_Surface* surf = PySurface_AsSurface(self);
 	const char* type;
 
-	type = (surf->flags&SDL_HWSURFACE)?"HW":"SW";
-	sprintf(str, "<Surface(%dx%dx%d %s)>", surf->w, surf->h, surf->format->BitsPerPixel, type);
+        if(surf)
+        {
+            type = (surf->flags&SDL_HWSURFACE)?"HW":"SW";
+            sprintf(str, "<Surface(%dx%dx%d %s)>", surf->w, surf->h, surf->format->BitsPerPixel, type);
+        }
+        else
+        {
+            strcpy(str, "<Surface(Dead Display)>");
+        }
 
 	return PyString_FromString(str);
 }