src/video/quartz/SDL_QuartzVideo.m
branchSDL-1.2
changeset 6157 8a1bc41db6bb
parent 6146 06ae169343e4
child 6158 6f3a2bb301d6
--- a/src/video/quartz/SDL_QuartzVideo.m	Tue Jan 03 01:41:17 2012 -0500
+++ b/src/video/quartz/SDL_QuartzVideo.m	Mon Jan 02 21:25:34 2012 -0800
@@ -1149,9 +1149,8 @@
     }
 
     if (qz_window != nil) {
-        NSGraphicsContext *ctx;
-        ctx = [NSGraphicsContext graphicsContextWithWindow:qz_window];
-        [NSGraphicsContext setCurrentContext:ctx];
+        nsgfx_context = [NSGraphicsContext graphicsContextWithWindow:qz_window];
+        [NSGraphicsContext setCurrentContext:nsgfx_context];
     }
 
     /* Setup the new pixel format */
@@ -1507,8 +1506,12 @@
     }
     
     else {
-        CGContextRef cgc = (CGContextRef)
-            [[NSGraphicsContext currentContext] graphicsPort];
+        NSGraphicsContext *ctx = [NSGraphicsContext currentContext];
+        if (ctx != nsgfx_context) { /* uhoh, you might be rendering from another thread... */
+            [NSGraphicsContext setCurrentContext:nsgfx_context];
+            ctx = nsgfx_context;
+        }
+        CGContextRef cgc = (CGContextRef) [ctx graphicsPort];
         QZ_DrawResizeIcon (this);
         CGContextFlush (cg_context);
         CGImageRef image = CGBitmapContextCreateImage (cg_context);