Fixed seg fault on video quit
authorNathan Heisey <nathanheisey@gmail.com>
Tue, 26 Jul 2011 10:13:34 +0000
changeset 5926 d9d57de9fb4e
parent 5925 262ce29aabf6
child 5927 463b84c19645
Fixed seg fault on video quit
src/video/bwindow/SDL_bmodes.cc
src/video/bwindow/SDL_bvideo.cc
src/video/bwindow/SDL_bvideo.h
src/video/bwindow/SDL_bwindow.h
--- a/src/video/bwindow/SDL_bmodes.cc	Mon Jul 25 16:46:55 2011 +0000
+++ b/src/video/bwindow/SDL_bmodes.cc	Tue Jul 26 10:13:34 2011 +0000
@@ -32,6 +32,13 @@
 extern "C" {
 #endif
 
+/* This wrapper is here so that the driverdata can be freed */
+typedef struct SDL_DisplayModeData {
+	display_mode *bmode;
+};
+
+
+
 static inline SDL_BWin *_ToBeWin(SDL_Window *window) {
 	return ((SDL_BWin*)(window->driverdata));
 }
@@ -107,8 +114,9 @@
 	mode->w = bmode->virtual_width;
 	mode->h = bmode->virtual_height;
 	mode->refresh_rate = (int)get_refresh_rate(*bmode);
-	mode->driverdata = bmode;	/* This makes setting display
-									   modes easier */
+	SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1, sizeof(SDL_DisplayModeData));
+	data->bmode = bmode;
+	mode->driverdata = data;
 
 	/* Set the format */
 	int32 bpp = ColorSpaceToBitsPerPixel(bmode->space);
@@ -191,7 +199,7 @@
 	BScreen bscreen;
 	
 	/* Set the mode using the driver data */
-	display_mode *bmode = (display_mode*)mode->driverdata;
+	display_mode *bmode = ((SDL_DisplayModeData*)mode->driverdata)->bmode;
 	if(bscreen.SetMode(bmode) == B_OK) {
 		return 0;	/* No error */
 	}
--- a/src/video/bwindow/SDL_bvideo.cc	Mon Jul 25 16:46:55 2011 +0000
+++ b/src/video/bwindow/SDL_bvideo.cc	Tue Jul 26 10:13:34 2011 +0000
@@ -59,10 +59,11 @@
 BE_CreateDevice(int devindex)
 {
     SDL_VideoDevice *device;
-    SDL_VideoData *data;
+    /*SDL_VideoData *data;*/
 
     /* Initialize all variables that we clean on shutdown */
     device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
+#if 0
     if (device) {
         data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
     } else {
@@ -75,7 +76,8 @@
         }
         return NULL;
     }
-    device->driverdata = data;
+#endif
+    device->driverdata = NULL; /*data;*/
 
 /* TODO: Figure out what sort of initialization needs to go here */
 
--- a/src/video/bwindow/SDL_bvideo.h	Mon Jul 25 16:46:55 2011 +0000
+++ b/src/video/bwindow/SDL_bvideo.h	Tue Jul 26 10:13:34 2011 +0000
@@ -29,9 +29,6 @@
 #include "../../main/beos/SDL_BeApp.h"
 #include "../SDL_sysvideo.h"
 
-typedef struct SDL_VideoData {
-	
-} SDL_VideoData;
 
 extern void BE_VideoQuit(_THIS);
 extern int BE_VideoInit(_THIS);
--- a/src/video/bwindow/SDL_bwindow.h	Mon Jul 25 16:46:55 2011 +0000
+++ b/src/video/bwindow/SDL_bwindow.h	Tue Jul 26 10:13:34 2011 +0000
@@ -25,6 +25,7 @@
 
 #include "../SDL_sysvideo.h"
 
+
 extern int BE_CreateWindow(_THIS, SDL_Window *window);
 extern int BE_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
 extern void BE_SetWindowTitle(_THIS, SDL_Window * window);