Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed seg fault on video quit
Browse files Browse the repository at this point in the history
  • Loading branch information
antifinidictor committed Jul 26, 2011
1 parent ae9722f commit 164ca8e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
14 changes: 11 additions & 3 deletions src/video/bwindow/SDL_bmodes.cc
Expand Up @@ -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));
}
Expand Down Expand Up @@ -107,8 +114,9 @@ static inline void BE_BDisplayModeToSdlDisplayMode(display_mode *bmode,
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);
Expand Down Expand Up @@ -191,7 +199,7 @@ int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){
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 */
}
Expand Down
6 changes: 4 additions & 2 deletions src/video/bwindow/SDL_bvideo.cc
Expand Up @@ -59,10 +59,11 @@ static SDL_VideoDevice *
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 {
Expand All @@ -75,7 +76,8 @@ BE_CreateDevice(int devindex)
}
return NULL;
}
device->driverdata = data;
#endif
device->driverdata = NULL; /*data;*/

/* TODO: Figure out what sort of initialization needs to go here */

Expand Down
3 changes: 0 additions & 3 deletions src/video/bwindow/SDL_bvideo.h
Expand Up @@ -29,9 +29,6 @@ extern "C" {
#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);
Expand Down
1 change: 1 addition & 0 deletions src/video/bwindow/SDL_bwindow.h
Expand Up @@ -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);
Expand Down

0 comments on commit 164ca8e

Please sign in to comment.