Anonymous avatar Anonymous committed c87dd74

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

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()
 /* 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)
 	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);
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.