src/video/bwindow/SDL_bmodes.cc
changeset 5926 d9d57de9fb4e
parent 5925 262ce29aabf6
child 5927 463b84c19645
     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  	}