diff options
| author | Steven Tamm | 2004-05-07 17:46:50 +0000 |
|---|---|---|
| committer | Steven Tamm | 2004-05-07 17:46:50 +0000 |
| commit | 2a316a84d5fdae6c12766c32144c15f45542360b (patch) | |
| tree | 898a5676d68b678c361065c86c76c92c93574e19 /src | |
| parent | 7daa20fca46a6dbce0cbca0a935a2798e210237e (diff) | |
| download | emacs-2a316a84d5fdae6c12766c32144c15f45542360b.tar.gz emacs-2a316a84d5fdae6c12766c32144c15f45542360b.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 15 | ||||
| -rw-r--r-- | src/image.c | 19 | ||||
| -rw-r--r-- | src/macterm.c | 32 |
3 files changed, 66 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index cf2201e95dd..938fa70227d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | 2004-05-07 Steven Tamm <steventamm@mac.com> | ||
| 2 | |||
| 3 | * macterm.c (mac_check_for_quit_char): Adding BLOCK_INPUT | ||
| 4 | around call to ReceiveEvent to avoid certain crashes. | ||
| 5 | |||
| 6 | 2004-05-07 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | ||
| 7 | * macterm.c (mac_draw_line_to_pixmap, XCreatePixmapFromBitmapData) | ||
| 8 | (mac_fill_rectangle_to_pixmap, mac_draw_rectangle_to_pixmap) | ||
| 9 | (mac_copy_area_to_pixmap, mac_copy_area_with_mask_to_pixmap): | ||
| 10 | Save/restore the current graphics port and device handle when | ||
| 11 | drawing into an offscreen graphics world. | ||
| 12 | |||
| 13 | * image.c [MAC_OS] (XPutPixel, XGetPixel, image_load_qt_1) | ||
| 14 | (gif_load): Likewise. | ||
| 15 | |||
| 1 | 2004-05-07 Juanma Barranquero <lektu@terra.es> | 16 | 2004-05-07 Juanma Barranquero <lektu@terra.es> |
| 2 | 17 | ||
| 3 | * window.c (Fset_window_buffer): Fix docstring. | 18 | * window.c (Fset_window_buffer): Fix docstring. |
diff --git a/src/image.c b/src/image.c index 09e497576a4..c7bedb5de32 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -174,14 +174,19 @@ XPutPixel (ximage, x, y, pixel) | |||
| 174 | int x, y; | 174 | int x, y; |
| 175 | unsigned long pixel; | 175 | unsigned long pixel; |
| 176 | { | 176 | { |
| 177 | CGrafPtr old_port; | ||
| 178 | GDHandle old_gdh; | ||
| 177 | RGBColor color; | 179 | RGBColor color; |
| 178 | 180 | ||
| 181 | GetGWorld (&old_port, &old_gdh); | ||
| 179 | SetGWorld (ximage, NULL); | 182 | SetGWorld (ximage, NULL); |
| 180 | 183 | ||
| 181 | color.red = RED16_FROM_ULONG (pixel); | 184 | color.red = RED16_FROM_ULONG (pixel); |
| 182 | color.green = GREEN16_FROM_ULONG (pixel); | 185 | color.green = GREEN16_FROM_ULONG (pixel); |
| 183 | color.blue = BLUE16_FROM_ULONG (pixel); | 186 | color.blue = BLUE16_FROM_ULONG (pixel); |
| 184 | SetCPixel (x, y, &color); | 187 | SetCPixel (x, y, &color); |
| 188 | |||
| 189 | SetGWorld (old_port, old_gdh); | ||
| 185 | } | 190 | } |
| 186 | 191 | ||
| 187 | static unsigned long | 192 | static unsigned long |
| @@ -189,11 +194,16 @@ XGetPixel (ximage, x, y) | |||
| 189 | XImagePtr ximage; | 194 | XImagePtr ximage; |
| 190 | int x, y; | 195 | int x, y; |
| 191 | { | 196 | { |
| 197 | CGrafPtr old_port; | ||
| 198 | GDHandle old_gdh; | ||
| 192 | RGBColor color; | 199 | RGBColor color; |
| 193 | 200 | ||
| 201 | GetGWorld (&old_port, &old_gdh); | ||
| 194 | SetGWorld (ximage, NULL); | 202 | SetGWorld (ximage, NULL); |
| 195 | 203 | ||
| 196 | GetCPixel (x, y, &color); | 204 | GetCPixel (x, y, &color); |
| 205 | |||
| 206 | SetGWorld (old_port, old_gdh); | ||
| 197 | return RGB_TO_ULONG (color.red >> 8, color.green >> 8, color.blue >> 8); | 207 | return RGB_TO_ULONG (color.red >> 8, color.green >> 8, color.blue >> 8); |
| 198 | } | 208 | } |
| 199 | 209 | ||
| @@ -2196,6 +2206,10 @@ image_load_qt_1 (f, img, type, fss, dh) | |||
| 2196 | goto error; | 2206 | goto error; |
| 2197 | if (draw_all_pixels != graphicsImporterDrawsAllPixels) | 2207 | if (draw_all_pixels != graphicsImporterDrawsAllPixels) |
| 2198 | { | 2208 | { |
| 2209 | CGrafPtr old_port; | ||
| 2210 | GDHandle old_gdh; | ||
| 2211 | |||
| 2212 | GetGWorld (&old_port, &old_gdh); | ||
| 2199 | SetGWorld (ximg, NULL); | 2213 | SetGWorld (ximg, NULL); |
| 2200 | bg_color.red = color.red; | 2214 | bg_color.red = color.red; |
| 2201 | bg_color.green = color.green; | 2215 | bg_color.green = color.green; |
| @@ -2207,6 +2221,7 @@ image_load_qt_1 (f, img, type, fss, dh) | |||
| 2207 | #else | 2221 | #else |
| 2208 | EraseRect (&(ximg->portRect)); | 2222 | EraseRect (&(ximg->portRect)); |
| 2209 | #endif | 2223 | #endif |
| 2224 | SetGWorld (old_port, old_gdh); | ||
| 2210 | } | 2225 | } |
| 2211 | GraphicsImportSetGWorld (gi, ximg, NULL); | 2226 | GraphicsImportSetGWorld (gi, ximg, NULL); |
| 2212 | GraphicsImportDraw (gi); | 2227 | GraphicsImportDraw (gi); |
| @@ -6883,6 +6898,8 @@ gif_load (f, img) | |||
| 6883 | TimeValue time; | 6898 | TimeValue time; |
| 6884 | struct gcpro gcpro1; | 6899 | struct gcpro gcpro1; |
| 6885 | int ino; | 6900 | int ino; |
| 6901 | CGrafPtr old_port; | ||
| 6902 | GDHandle old_gdh; | ||
| 6886 | 6903 | ||
| 6887 | specified_file = image_spec_value (img->spec, QCfile, NULL); | 6904 | specified_file = image_spec_value (img->spec, QCfile, NULL); |
| 6888 | specified_data = image_spec_value (img->spec, QCdata, NULL); | 6905 | specified_data = image_spec_value (img->spec, QCdata, NULL); |
| @@ -7000,11 +7017,13 @@ gif_load (f, img) | |||
| 7000 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) | 7017 | if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) |
| 7001 | goto error; | 7018 | goto error; |
| 7002 | 7019 | ||
| 7020 | GetGWorld (&old_port, &old_gdh); | ||
| 7003 | SetGWorld (ximg, NULL); | 7021 | SetGWorld (ximg, NULL); |
| 7004 | bg_color.red = color.red; | 7022 | bg_color.red = color.red; |
| 7005 | bg_color.green = color.green; | 7023 | bg_color.green = color.green; |
| 7006 | bg_color.blue = color.blue; | 7024 | bg_color.blue = color.blue; |
| 7007 | RGBBackColor (&bg_color); | 7025 | RGBBackColor (&bg_color); |
| 7026 | SetGWorld (old_port, old_gdh); | ||
| 7008 | SetMovieActive (movie, TRUE); | 7027 | SetMovieActive (movie, TRUE); |
| 7009 | SetMovieGWorld (movie, ximg, NULL); | 7028 | SetMovieGWorld (movie, ximg, NULL); |
| 7010 | SampleNumToMediaTime (media, ino + 1, &time, NULL); | 7029 | SampleNumToMediaTime (media, ino + 1, &time, NULL); |
diff --git a/src/macterm.c b/src/macterm.c index fdb61249629..9b81c0ccc4f 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -383,6 +383,10 @@ mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2) | |||
| 383 | GC gc; | 383 | GC gc; |
| 384 | int x1, y1, x2, y2; | 384 | int x1, y1, x2, y2; |
| 385 | { | 385 | { |
| 386 | CGrafPtr old_port; | ||
| 387 | GDHandle old_gdh; | ||
| 388 | |||
| 389 | GetGWorld (&old_port, &old_gdh); | ||
| 386 | SetGWorld (p, NULL); | 390 | SetGWorld (p, NULL); |
| 387 | 391 | ||
| 388 | mac_set_colors (gc); | 392 | mac_set_colors (gc); |
| @@ -391,6 +395,8 @@ mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2) | |||
| 391 | MoveTo (x1, y1); | 395 | MoveTo (x1, y1); |
| 392 | LineTo (x2, y2); | 396 | LineTo (x2, y2); |
| 393 | UnlockPixels (GetGWorldPixMap (p)); | 397 | UnlockPixels (GetGWorldPixMap (p)); |
| 398 | |||
| 399 | SetGWorld (old_port, old_gdh); | ||
| 394 | } | 400 | } |
| 395 | 401 | ||
| 396 | /* Mac version of XClearArea. */ | 402 | /* Mac version of XClearArea. */ |
| @@ -620,11 +626,14 @@ XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth) | |||
| 620 | { | 626 | { |
| 621 | Pixmap pixmap; | 627 | Pixmap pixmap; |
| 622 | BitMap bitmap; | 628 | BitMap bitmap; |
| 629 | CGrafPtr old_port; | ||
| 630 | GDHandle old_gdh; | ||
| 623 | 631 | ||
| 624 | pixmap = XCreatePixmap (display, w, width, height, depth); | 632 | pixmap = XCreatePixmap (display, w, width, height, depth); |
| 625 | if (pixmap == NULL) | 633 | if (pixmap == NULL) |
| 626 | return NULL; | 634 | return NULL; |
| 627 | 635 | ||
| 636 | GetGWorld (&old_port, &old_gdh); | ||
| 628 | SetGWorld (pixmap, NULL); | 637 | SetGWorld (pixmap, NULL); |
| 629 | mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height); | 638 | mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height); |
| 630 | mac_set_forecolor (fg); | 639 | mac_set_forecolor (fg); |
| @@ -638,6 +647,7 @@ XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth) | |||
| 638 | &bitmap.bounds, &bitmap.bounds, srcCopy, 0); | 647 | &bitmap.bounds, &bitmap.bounds, srcCopy, 0); |
| 639 | #endif /* not TARGET_API_MAC_CARBON */ | 648 | #endif /* not TARGET_API_MAC_CARBON */ |
| 640 | UnlockPixels (GetGWorldPixMap (pixmap)); | 649 | UnlockPixels (GetGWorldPixMap (pixmap)); |
| 650 | SetGWorld (old_port, old_gdh); | ||
| 641 | mac_free_bitmap (&bitmap); | 651 | mac_free_bitmap (&bitmap); |
| 642 | 652 | ||
| 643 | return pixmap; | 653 | return pixmap; |
| @@ -677,8 +687,11 @@ mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height) | |||
| 677 | int x, y; | 687 | int x, y; |
| 678 | unsigned int width, height; | 688 | unsigned int width, height; |
| 679 | { | 689 | { |
| 690 | CGrafPtr old_port; | ||
| 691 | GDHandle old_gdh; | ||
| 680 | Rect r; | 692 | Rect r; |
| 681 | 693 | ||
| 694 | GetGWorld (&old_port, &old_gdh); | ||
| 682 | SetGWorld (p, NULL); | 695 | SetGWorld (p, NULL); |
| 683 | mac_set_colors (gc); | 696 | mac_set_colors (gc); |
| 684 | SetRect (&r, x, y, x + width, y + height); | 697 | SetRect (&r, x, y, x + width, y + height); |
| @@ -686,6 +699,8 @@ mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height) | |||
| 686 | LockPixels (GetGWorldPixMap (p)); | 699 | LockPixels (GetGWorldPixMap (p)); |
| 687 | PaintRect (&r); /* using foreground color of gc */ | 700 | PaintRect (&r); /* using foreground color of gc */ |
| 688 | UnlockPixels (GetGWorldPixMap (p)); | 701 | UnlockPixels (GetGWorldPixMap (p)); |
| 702 | |||
| 703 | SetGWorld (old_port, old_gdh); | ||
| 689 | } | 704 | } |
| 690 | 705 | ||
| 691 | 706 | ||
| @@ -724,8 +739,11 @@ mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height) | |||
| 724 | int x, y; | 739 | int x, y; |
| 725 | unsigned int width, height; | 740 | unsigned int width, height; |
| 726 | { | 741 | { |
| 742 | CGrafPtr old_port; | ||
| 743 | GDHandle old_gdh; | ||
| 727 | Rect r; | 744 | Rect r; |
| 728 | 745 | ||
| 746 | GetGWorld (&old_port, &old_gdh); | ||
| 729 | SetGWorld (p, NULL); | 747 | SetGWorld (p, NULL); |
| 730 | mac_set_colors (gc); | 748 | mac_set_colors (gc); |
| 731 | SetRect (&r, x, y, x + width + 1, y + height + 1); | 749 | SetRect (&r, x, y, x + width + 1, y + height + 1); |
| @@ -733,6 +751,8 @@ mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height) | |||
| 733 | LockPixels (GetGWorldPixMap (p)); | 751 | LockPixels (GetGWorldPixMap (p)); |
| 734 | FrameRect (&r); /* using foreground color of gc */ | 752 | FrameRect (&r); /* using foreground color of gc */ |
| 735 | UnlockPixels (GetGWorldPixMap (p)); | 753 | UnlockPixels (GetGWorldPixMap (p)); |
| 754 | |||
| 755 | SetGWorld (old_port, old_gdh); | ||
| 736 | } | 756 | } |
| 737 | 757 | ||
| 738 | 758 | ||
| @@ -1003,8 +1023,11 @@ mac_copy_area_to_pixmap (display, src, dest, gc, src_x, src_y, width, height, | |||
| 1003 | unsigned int width, height; | 1023 | unsigned int width, height; |
| 1004 | int dest_x, dest_y; | 1024 | int dest_x, dest_y; |
| 1005 | { | 1025 | { |
| 1026 | CGrafPtr old_port; | ||
| 1027 | GDHandle old_gdh; | ||
| 1006 | Rect src_r, dest_r; | 1028 | Rect src_r, dest_r; |
| 1007 | 1029 | ||
| 1030 | GetGWorld (&old_port, &old_gdh); | ||
| 1008 | SetGWorld (dest, NULL); | 1031 | SetGWorld (dest, NULL); |
| 1009 | ForeColor (blackColor); | 1032 | ForeColor (blackColor); |
| 1010 | BackColor (whiteColor); | 1033 | BackColor (whiteColor); |
| @@ -1023,6 +1046,8 @@ mac_copy_area_to_pixmap (display, src, dest, gc, src_x, src_y, width, height, | |||
| 1023 | #endif /* not TARGET_API_MAC_CARBON */ | 1046 | #endif /* not TARGET_API_MAC_CARBON */ |
| 1024 | UnlockPixels (GetGWorldPixMap (dest)); | 1047 | UnlockPixels (GetGWorldPixMap (dest)); |
| 1025 | UnlockPixels (GetGWorldPixMap (src)); | 1048 | UnlockPixels (GetGWorldPixMap (src)); |
| 1049 | |||
| 1050 | SetGWorld (old_port, old_gdh); | ||
| 1026 | } | 1051 | } |
| 1027 | 1052 | ||
| 1028 | 1053 | ||
| @@ -1036,8 +1061,11 @@ mac_copy_area_with_mask_to_pixmap (display, src, mask, dest, gc, src_x, src_y, | |||
| 1036 | unsigned int width, height; | 1061 | unsigned int width, height; |
| 1037 | int dest_x, dest_y; | 1062 | int dest_x, dest_y; |
| 1038 | { | 1063 | { |
| 1064 | CGrafPtr old_port; | ||
| 1065 | GDHandle old_gdh; | ||
| 1039 | Rect src_r, dest_r; | 1066 | Rect src_r, dest_r; |
| 1040 | 1067 | ||
| 1068 | GetGWorld (&old_port, &old_gdh); | ||
| 1041 | SetGWorld (dest, NULL); | 1069 | SetGWorld (dest, NULL); |
| 1042 | ForeColor (blackColor); | 1070 | ForeColor (blackColor); |
| 1043 | BackColor (whiteColor); | 1071 | BackColor (whiteColor); |
| @@ -1058,6 +1086,8 @@ mac_copy_area_with_mask_to_pixmap (display, src, mask, dest, gc, src_x, src_y, | |||
| 1058 | UnlockPixels (GetGWorldPixMap (dest)); | 1086 | UnlockPixels (GetGWorldPixMap (dest)); |
| 1059 | UnlockPixels (GetGWorldPixMap (mask)); | 1087 | UnlockPixels (GetGWorldPixMap (mask)); |
| 1060 | UnlockPixels (GetGWorldPixMap (src)); | 1088 | UnlockPixels (GetGWorldPixMap (src)); |
| 1089 | |||
| 1090 | SetGWorld (old_port, old_gdh); | ||
| 1061 | } | 1091 | } |
| 1062 | 1092 | ||
| 1063 | 1093 | ||
| @@ -8980,9 +9010,11 @@ mac_check_for_quit_char () | |||
| 8980 | mac_determine_quit_char_modifiers (); | 9010 | mac_determine_quit_char_modifiers (); |
| 8981 | 9011 | ||
| 8982 | /* Fill the queue with events */ | 9012 | /* Fill the queue with events */ |
| 9013 | BLOCK_INPUT; | ||
| 8983 | ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &event); | 9014 | ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &event); |
| 8984 | event = FindSpecificEventInQueue (GetMainEventQueue (), quit_char_comp, | 9015 | event = FindSpecificEventInQueue (GetMainEventQueue (), quit_char_comp, |
| 8985 | NULL); | 9016 | NULL); |
| 9017 | UNBLOCK_INPUT; | ||
| 8986 | if (event) | 9018 | if (event) |
| 8987 | { | 9019 | { |
| 8988 | struct input_event e; | 9020 | struct input_event e; |