Fixed seg fault on video quit
authorNathan Heisey <nathanheisey@gmail.com>
Tue, 26 Jul 2011 10:13:34 +0000
changeset 5926d9d57de9fb4e
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
     1.1 --- a/src/video/bwindow/SDL_bmodes.cc	Mon Jul 25 16:46:55 2011 +0000
     1.2 +++ b/src/video/bwindow/SDL_bmodes.cc	Tue Jul 26 10:13:34 2011 +0000
     1.3 @@ -32,6 +32,13 @@
     1.4  extern "C" {
     1.5  #endif
     1.6  
     1.7 +/* This wrapper is here so that the driverdata can be freed */
     1.8 +typedef struct SDL_DisplayModeData {
     1.9 +	display_mode *bmode;
    1.10 +};
    1.11 +
    1.12 +
    1.13 +
    1.14  static inline SDL_BWin *_ToBeWin(SDL_Window *window) {
    1.15  	return ((SDL_BWin*)(window->driverdata));
    1.16  }
    1.17 @@ -107,8 +114,9 @@
    1.18  	mode->w = bmode->virtual_width;
    1.19  	mode->h = bmode->virtual_height;
    1.20  	mode->refresh_rate = (int)get_refresh_rate(*bmode);
    1.21 -	mode->driverdata = bmode;	/* This makes setting display
    1.22 -									   modes easier */
    1.23 +	SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1, sizeof(SDL_DisplayModeData));
    1.24 +	data->bmode = bmode;
    1.25 +	mode->driverdata = data;
    1.26  
    1.27  	/* Set the format */
    1.28  	int32 bpp = ColorSpaceToBitsPerPixel(bmode->space);
    1.29 @@ -191,7 +199,7 @@
    1.30  	BScreen bscreen;
    1.31  	
    1.32  	/* Set the mode using the driver data */
    1.33 -	display_mode *bmode = (display_mode*)mode->driverdata;
    1.34 +	display_mode *bmode = ((SDL_DisplayModeData*)mode->driverdata)->bmode;
    1.35  	if(bscreen.SetMode(bmode) == B_OK) {
    1.36  		return 0;	/* No error */
    1.37  	}
     2.1 --- a/src/video/bwindow/SDL_bvideo.cc	Mon Jul 25 16:46:55 2011 +0000
     2.2 +++ b/src/video/bwindow/SDL_bvideo.cc	Tue Jul 26 10:13:34 2011 +0000
     2.3 @@ -59,10 +59,11 @@
     2.4  BE_CreateDevice(int devindex)
     2.5  {
     2.6      SDL_VideoDevice *device;
     2.7 -    SDL_VideoData *data;
     2.8 +    /*SDL_VideoData *data;*/
     2.9  
    2.10      /* Initialize all variables that we clean on shutdown */
    2.11      device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
    2.12 +#if 0
    2.13      if (device) {
    2.14          data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
    2.15      } else {
    2.16 @@ -75,7 +76,8 @@
    2.17          }
    2.18          return NULL;
    2.19      }
    2.20 -    device->driverdata = data;
    2.21 +#endif
    2.22 +    device->driverdata = NULL; /*data;*/
    2.23  
    2.24  /* TODO: Figure out what sort of initialization needs to go here */
    2.25  
     3.1 --- a/src/video/bwindow/SDL_bvideo.h	Mon Jul 25 16:46:55 2011 +0000
     3.2 +++ b/src/video/bwindow/SDL_bvideo.h	Tue Jul 26 10:13:34 2011 +0000
     3.3 @@ -29,9 +29,6 @@
     3.4  #include "../../main/beos/SDL_BeApp.h"
     3.5  #include "../SDL_sysvideo.h"
     3.6  
     3.7 -typedef struct SDL_VideoData {
     3.8 -	
     3.9 -} SDL_VideoData;
    3.10  
    3.11  extern void BE_VideoQuit(_THIS);
    3.12  extern int BE_VideoInit(_THIS);
     4.1 --- a/src/video/bwindow/SDL_bwindow.h	Mon Jul 25 16:46:55 2011 +0000
     4.2 +++ b/src/video/bwindow/SDL_bwindow.h	Tue Jul 26 10:13:34 2011 +0000
     4.3 @@ -25,6 +25,7 @@
     4.4  
     4.5  #include "../SDL_sysvideo.h"
     4.6  
     4.7 +
     4.8  extern int BE_CreateWindow(_THIS, SDL_Window *window);
     4.9  extern int BE_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
    4.10  extern void BE_SetWindowTitle(_THIS, SDL_Window * window);