# HG changeset patch # User Steven Tamm # Date 1083952010 0 # Node ID 53a1a79a33f91a3764ea205b4715e0b24d078315 # Parent d0e0914b0f6d6472494a07f89386c6b7e481f920 macterm.c (mac_check_for_quit_char): Adding BLOCK_INPUT around call to ReceiveEvent to avoid certain crashes. (mac_draw_line_to_pixmap, XCreatePixmapFromBitmapData) (mac_fill_rectangle_to_pixmap, mac_draw_rectangle_to_pixmap) (mac_copy_area_to_pixmap, mac_copy_area_with_mask_to_pixmap): Save/restore the current graphics port and device handle when drawing into an offscreen graphics world. image.c [MAC_OS] (XPutPixel, XGetPixel, image_load_qt_1) (gif_load): Likewise. diff -r d0e0914b0f6d -r 53a1a79a33f9 src/ChangeLog --- a/src/ChangeLog Fri May 07 16:10:25 2004 +0000 +++ b/src/ChangeLog Fri May 07 17:46:50 2004 +0000 @@ -1,3 +1,18 @@ +2004-05-07 Steven Tamm + + * macterm.c (mac_check_for_quit_char): Adding BLOCK_INPUT + around call to ReceiveEvent to avoid certain crashes. + +2004-05-07 YAMAMOTO Mitsuharu + * macterm.c (mac_draw_line_to_pixmap, XCreatePixmapFromBitmapData) + (mac_fill_rectangle_to_pixmap, mac_draw_rectangle_to_pixmap) + (mac_copy_area_to_pixmap, mac_copy_area_with_mask_to_pixmap): + Save/restore the current graphics port and device handle when + drawing into an offscreen graphics world. + + * image.c [MAC_OS] (XPutPixel, XGetPixel, image_load_qt_1) + (gif_load): Likewise. + 2004-05-07 Juanma Barranquero * window.c (Fset_window_buffer): Fix docstring. diff -r d0e0914b0f6d -r 53a1a79a33f9 src/image.c --- a/src/image.c Fri May 07 16:10:25 2004 +0000 +++ b/src/image.c Fri May 07 17:46:50 2004 +0000 @@ -174,14 +174,19 @@ int x, y; unsigned long pixel; { + CGrafPtr old_port; + GDHandle old_gdh; RGBColor color; + GetGWorld (&old_port, &old_gdh); SetGWorld (ximage, NULL); color.red = RED16_FROM_ULONG (pixel); color.green = GREEN16_FROM_ULONG (pixel); color.blue = BLUE16_FROM_ULONG (pixel); SetCPixel (x, y, &color); + + SetGWorld (old_port, old_gdh); } static unsigned long @@ -189,11 +194,16 @@ XImagePtr ximage; int x, y; { + CGrafPtr old_port; + GDHandle old_gdh; RGBColor color; + GetGWorld (&old_port, &old_gdh); SetGWorld (ximage, NULL); GetCPixel (x, y, &color); + + SetGWorld (old_port, old_gdh); return RGB_TO_ULONG (color.red >> 8, color.green >> 8, color.blue >> 8); } @@ -2196,6 +2206,10 @@ goto error; if (draw_all_pixels != graphicsImporterDrawsAllPixels) { + CGrafPtr old_port; + GDHandle old_gdh; + + GetGWorld (&old_port, &old_gdh); SetGWorld (ximg, NULL); bg_color.red = color.red; bg_color.green = color.green; @@ -2207,6 +2221,7 @@ #else EraseRect (&(ximg->portRect)); #endif + SetGWorld (old_port, old_gdh); } GraphicsImportSetGWorld (gi, ximg, NULL); GraphicsImportDraw (gi); @@ -6883,6 +6898,8 @@ TimeValue time; struct gcpro gcpro1; int ino; + CGrafPtr old_port; + GDHandle old_gdh; specified_file = image_spec_value (img->spec, QCfile, NULL); specified_data = image_spec_value (img->spec, QCdata, NULL); @@ -7000,11 +7017,13 @@ if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) goto error; + GetGWorld (&old_port, &old_gdh); SetGWorld (ximg, NULL); bg_color.red = color.red; bg_color.green = color.green; bg_color.blue = color.blue; RGBBackColor (&bg_color); + SetGWorld (old_port, old_gdh); SetMovieActive (movie, TRUE); SetMovieGWorld (movie, ximg, NULL); SampleNumToMediaTime (media, ino + 1, &time, NULL); diff -r d0e0914b0f6d -r 53a1a79a33f9 src/macterm.c --- a/src/macterm.c Fri May 07 16:10:25 2004 +0000 +++ b/src/macterm.c Fri May 07 17:46:50 2004 +0000 @@ -383,6 +383,10 @@ GC gc; int x1, y1, x2, y2; { + CGrafPtr old_port; + GDHandle old_gdh; + + GetGWorld (&old_port, &old_gdh); SetGWorld (p, NULL); mac_set_colors (gc); @@ -391,6 +395,8 @@ MoveTo (x1, y1); LineTo (x2, y2); UnlockPixels (GetGWorldPixMap (p)); + + SetGWorld (old_port, old_gdh); } /* Mac version of XClearArea. */ @@ -620,11 +626,14 @@ { Pixmap pixmap; BitMap bitmap; + CGrafPtr old_port; + GDHandle old_gdh; pixmap = XCreatePixmap (display, w, width, height, depth); if (pixmap == NULL) return NULL; + GetGWorld (&old_port, &old_gdh); SetGWorld (pixmap, NULL); mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height); mac_set_forecolor (fg); @@ -638,6 +647,7 @@ &bitmap.bounds, &bitmap.bounds, srcCopy, 0); #endif /* not TARGET_API_MAC_CARBON */ UnlockPixels (GetGWorldPixMap (pixmap)); + SetGWorld (old_port, old_gdh); mac_free_bitmap (&bitmap); return pixmap; @@ -677,8 +687,11 @@ int x, y; unsigned int width, height; { + CGrafPtr old_port; + GDHandle old_gdh; Rect r; + GetGWorld (&old_port, &old_gdh); SetGWorld (p, NULL); mac_set_colors (gc); SetRect (&r, x, y, x + width, y + height); @@ -686,6 +699,8 @@ LockPixels (GetGWorldPixMap (p)); PaintRect (&r); /* using foreground color of gc */ UnlockPixels (GetGWorldPixMap (p)); + + SetGWorld (old_port, old_gdh); } @@ -724,8 +739,11 @@ int x, y; unsigned int width, height; { + CGrafPtr old_port; + GDHandle old_gdh; Rect r; + GetGWorld (&old_port, &old_gdh); SetGWorld (p, NULL); mac_set_colors (gc); SetRect (&r, x, y, x + width + 1, y + height + 1); @@ -733,6 +751,8 @@ LockPixels (GetGWorldPixMap (p)); FrameRect (&r); /* using foreground color of gc */ UnlockPixels (GetGWorldPixMap (p)); + + SetGWorld (old_port, old_gdh); } @@ -1003,8 +1023,11 @@ unsigned int width, height; int dest_x, dest_y; { + CGrafPtr old_port; + GDHandle old_gdh; Rect src_r, dest_r; + GetGWorld (&old_port, &old_gdh); SetGWorld (dest, NULL); ForeColor (blackColor); BackColor (whiteColor); @@ -1023,6 +1046,8 @@ #endif /* not TARGET_API_MAC_CARBON */ UnlockPixels (GetGWorldPixMap (dest)); UnlockPixels (GetGWorldPixMap (src)); + + SetGWorld (old_port, old_gdh); } @@ -1036,8 +1061,11 @@ unsigned int width, height; int dest_x, dest_y; { + CGrafPtr old_port; + GDHandle old_gdh; Rect src_r, dest_r; + GetGWorld (&old_port, &old_gdh); SetGWorld (dest, NULL); ForeColor (blackColor); BackColor (whiteColor); @@ -1058,6 +1086,8 @@ UnlockPixels (GetGWorldPixMap (dest)); UnlockPixels (GetGWorldPixMap (mask)); UnlockPixels (GetGWorldPixMap (src)); + + SetGWorld (old_port, old_gdh); } @@ -8980,9 +9010,11 @@ mac_determine_quit_char_modifiers (); /* Fill the queue with events */ + BLOCK_INPUT; ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &event); event = FindSpecificEventInQueue (GetMainEventQueue (), quit_char_comp, NULL); + UNBLOCK_INPUT; if (event) { struct input_event e;