Commit 7121f4e5 authored by Nathan Heisey's avatar Nathan Heisey

Fixed seg fault on video quit

parent 20af8e06
...@@ -32,6 +32,13 @@ ...@@ -32,6 +32,13 @@
extern "C" { extern "C" {
#endif #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) { static inline SDL_BWin *_ToBeWin(SDL_Window *window) {
return ((SDL_BWin*)(window->driverdata)); return ((SDL_BWin*)(window->driverdata));
} }
...@@ -107,8 +114,9 @@ static inline void BE_BDisplayModeToSdlDisplayMode(display_mode *bmode, ...@@ -107,8 +114,9 @@ static inline void BE_BDisplayModeToSdlDisplayMode(display_mode *bmode,
mode->w = bmode->virtual_width; mode->w = bmode->virtual_width;
mode->h = bmode->virtual_height; mode->h = bmode->virtual_height;
mode->refresh_rate = (int)get_refresh_rate(*bmode); mode->refresh_rate = (int)get_refresh_rate(*bmode);
mode->driverdata = bmode; /* This makes setting display SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1, sizeof(SDL_DisplayModeData));
modes easier */ data->bmode = bmode;
mode->driverdata = data;
/* Set the format */ /* Set the format */
int32 bpp = ColorSpaceToBitsPerPixel(bmode->space); int32 bpp = ColorSpaceToBitsPerPixel(bmode->space);
...@@ -191,7 +199,7 @@ int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){ ...@@ -191,7 +199,7 @@ int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){
BScreen bscreen; BScreen bscreen;
/* Set the mode using the driver data */ /* 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) { if(bscreen.SetMode(bmode) == B_OK) {
return 0; /* No error */ return 0; /* No error */
} }
......
...@@ -59,10 +59,11 @@ static SDL_VideoDevice * ...@@ -59,10 +59,11 @@ static SDL_VideoDevice *
BE_CreateDevice(int devindex) BE_CreateDevice(int devindex)
{ {
SDL_VideoDevice *device; SDL_VideoDevice *device;
SDL_VideoData *data; /*SDL_VideoData *data;*/
/* Initialize all variables that we clean on shutdown */ /* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
#if 0
if (device) { if (device) {
data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
} else { } else {
...@@ -75,7 +76,8 @@ BE_CreateDevice(int devindex) ...@@ -75,7 +76,8 @@ BE_CreateDevice(int devindex)
} }
return NULL; return NULL;
} }
device->driverdata = data; #endif
device->driverdata = NULL; /*data;*/
/* TODO: Figure out what sort of initialization needs to go here */ /* TODO: Figure out what sort of initialization needs to go here */
......
...@@ -29,9 +29,6 @@ extern "C" { ...@@ -29,9 +29,6 @@ extern "C" {
#include "../../main/beos/SDL_BeApp.h" #include "../../main/beos/SDL_BeApp.h"
#include "../SDL_sysvideo.h" #include "../SDL_sysvideo.h"
typedef struct SDL_VideoData {
} SDL_VideoData;
extern void BE_VideoQuit(_THIS); extern void BE_VideoQuit(_THIS);
extern int BE_VideoInit(_THIS); extern int BE_VideoInit(_THIS);
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "../SDL_sysvideo.h" #include "../SDL_sysvideo.h"
extern int BE_CreateWindow(_THIS, SDL_Window *window); extern int BE_CreateWindow(_THIS, SDL_Window *window);
extern int BE_CreateWindowFrom(_THIS, SDL_Window * window, const void *data); extern int BE_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
extern void BE_SetWindowTitle(_THIS, SDL_Window * window); extern void BE_SetWindowTitle(_THIS, SDL_Window * window);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment