Patch by me to fix crash described below.
authorRyan C. Gordon
Thu, 18 Aug 2005 06:46:32 +0000
changeset 11208e1fde455471
parent 1119 430d8d701f69
child 1121 7c3aa6e87a05
Patch by me to fix crash described below.

--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;
}
src/video/quartz/SDL_QuartzVideo.m
     1.1 --- a/src/video/quartz/SDL_QuartzVideo.m	Thu Aug 18 06:18:30 2005 +0000
     1.2 +++ b/src/video/quartz/SDL_QuartzVideo.m	Thu Aug 18 06:46:32 2005 +0000
     1.3 @@ -95,6 +95,7 @@
     1.4  #endif
     1.5  static int  QZ_LockHWSurface(_THIS, SDL_Surface *surface);
     1.6  static void QZ_UnlockHWSurface(_THIS, SDL_Surface *surface);
     1.7 +static int QZ_AllocHWSurface(_THIS, SDL_Surface *surface);
     1.8  static void QZ_FreeHWSurface (_THIS, SDL_Surface *surface);
     1.9  /* static int  QZ_FlipHWSurface (_THIS, SDL_Surface *surface); */
    1.10  
    1.11 @@ -137,6 +138,7 @@
    1.12  
    1.13      device->LockHWSurface   = QZ_LockHWSurface;
    1.14      device->UnlockHWSurface = QZ_UnlockHWSurface;
    1.15 +    device->AllocHWSurface   = QZ_AllocHWSurface;
    1.16      device->FreeHWSurface   = QZ_FreeHWSurface;
    1.17      /* device->FlipHWSurface   = QZ_FlipHWSurface */;
    1.18  
    1.19 @@ -1506,6 +1508,10 @@
    1.20  
    1.21  }
    1.22  
    1.23 +static int QZ_AllocHWSurface(_THIS, SDL_Surface *surface) {
    1.24 +    return(-1); /* unallowed (no HWSURFACE support here). */
    1.25 +}
    1.26 +
    1.27  static void QZ_FreeHWSurface (_THIS, SDL_Surface *surface) {
    1.28  }
    1.29