Skip to content

Commit

Permalink
Patch by me to fix crash described below.
Browse files Browse the repository at this point in the history
--ryan.



To: sdl@libsdl.org
From: Rainer Deyke <rainerd@eldwood.com>
Date: Tue, 16 Aug 2005 01:08:18 -0600
Subject: [SDL] Bug report: SDL_CreateRGBSurface with SDL_HWSURFACE crashes

If SDL is in full-screen mode with a hardware video surface on OS X,
SDL_CreateRGBSurface with SDL_HWSURFACE crashes.  The crash occurs on
line 109 of SDL_Surface.c.  This was tested on OS X 10.3.9 with both SDL
1.2.8 and the latest CVS.  Here is a small C++ program that demonstrates
the problem:

#include "SDL.h"
#include <stdio.h>

namespace {

   void wait_for_key()
   {
     SDL_Event e;
     printf("%d\n", SDL_GetAppState());
     while (SDL_WaitEvent(&e)) {
       if (e.type == SDL_KEYDOWN || e.type == SDL_QUIT) return;
     }
   }

}

int main(int, char *[])
{
   SDL_Init(SDL_INIT_VIDEO);
   SDL_Surface *screen
     = SDL_SetVideoMode(640, 480, 32, SDL_FULLSCREEN | SDL_HWSURFACE);
   SDL_Surface *s = SDL_CreateRGBSurface(SDL_HWSURFACE, 640, 480, 32,
       screen->format->Rmask, screen->format->Gmask,
       screen->format->Bmask, screen->format->Amask);
   wait_for_key();
   if (s) SDL_FreeSurface(s);
   SDL_Quit();
   printf("Success!\n");
   return 0;
}
  • Loading branch information
icculus committed Aug 18, 2005
1 parent a54c2de commit 2de27b3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/video/quartz/SDL_QuartzVideo.m
Expand Up @@ -95,6 +95,7 @@ static int QZ_SetColors (_THIS, int first_color,
#endif
static int QZ_LockHWSurface(_THIS, SDL_Surface *surface);
static void QZ_UnlockHWSurface(_THIS, SDL_Surface *surface);
static int QZ_AllocHWSurface(_THIS, SDL_Surface *surface);
static void QZ_FreeHWSurface (_THIS, SDL_Surface *surface);
/* static int QZ_FlipHWSurface (_THIS, SDL_Surface *surface); */

Expand Down Expand Up @@ -137,6 +138,7 @@ static int QZ_Available () {

device->LockHWSurface = QZ_LockHWSurface;
device->UnlockHWSurface = QZ_UnlockHWSurface;
device->AllocHWSurface = QZ_AllocHWSurface;
device->FreeHWSurface = QZ_FreeHWSurface;
/* device->FlipHWSurface = QZ_FlipHWSurface */;

Expand Down Expand Up @@ -1506,6 +1508,10 @@ static void QZ_UnlockHWSurface(_THIS, SDL_Surface *surface) {

}

static int QZ_AllocHWSurface(_THIS, SDL_Surface *surface) {
return(-1); /* unallowed (no HWSURFACE support here). */
}

static void QZ_FreeHWSurface (_THIS, SDL_Surface *surface) {
}

Expand Down

0 comments on commit 2de27b3

Please sign in to comment.