Hello everyone,
We recently fixed an issue in libSDL 1.2.14 when running on MacBookPros with their dual video modes that can change dynamically. We found that even after a screen context had been created, the hardware providing the display could dynamically change and subsequent drawing would crash our application.
The following change to src/video/quartz/SDL_QuartzVideo.m fixed the issue for us:
Code:
static int QZ_LockHWSurface(_THIS, SDL_Surface surface)
{
if (surface == SDL_VideoSurface) { // %%KAB: Always get latest bitmap address and rowbytes since they can change dynamically!!!
surface->pixels = (void) CGDisplayBaseAddress (kCGDirectMainDisplay);
surface->pitch = CGDisplayBytesPerRow (kCGDirectMainDisplay);
return (surface->pixels != NULL);
}
return 1;
}
We made another change to comment out a CGContextRelease() on an already autoreleased object in this function (same source file) :
Code:
static void QZ_UpdateRects (_THIS, int numRects, SDL_Rect *rects)
{
if (SDL_VideoSurface->flags & SDL_OPENGLBLIT) {
QZ_GL_SwapBuffers (this);
}
else if ( [ qz_window isMiniaturized ] ) {
/* Do nothing if miniaturized */
}
else {
CGContextRef cgc = (CGContextRef)
[[NSGraphicsContext graphicsContextWithWindow: qz_window]
graphicsPort];
QZ_DrawResizeIcon (this);
CGContextFlush (cg_context);
CGImageRef image = CGBitmapContextCreateImage (cg_context);
CGRect rectangle = CGRectMake (0,0,[window_view frame].size.width,[window_view frame].size.height);
CGContextDrawImage (cgc, rectangle, image);
CGImageRelease(image);
CGContextFlush (cgc);
//CGContextRelease (cgc); // %%KAB: this object was already autoreleased when obtained above.
}
}
All of my code changes are marked with a comment with my initials.
Kind regards,
-Kirk
Kirk A. Baker
Senior Software Engineer
Camera Bits, Inc.