From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: YAMAMOTO Mitsuharu Newsgroups: gmane.emacs.devel Subject: Re: More info on sporadic OS/X crash Date: Sat, 01 May 2004 20:09:15 +0900 Organization: Faculty of Science, Chiba University Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 (generated by SEMI 1.14.5 - "Awara-Onsen") Content-Type: text/plain; charset=US-ASCII X-Trace: sea.gmane.org 1083411012 16537 80.91.224.253 (1 May 2004 11:30:12 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 1 May 2004 11:30:12 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sat May 01 13:30:01 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BJsgz-0006PB-00 for ; Sat, 01 May 2004 13:30:01 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BJsgn-0001Ml-00 for ; Sat, 01 May 2004 13:30:00 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BJsfD-0008W7-UG for emacs-devel@quimby.gnus.org; Sat, 01 May 2004 07:28:11 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BJsVh-00078t-6U for emacs-devel@gnu.org; Sat, 01 May 2004 07:18:21 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BJsPS-0006Fp-Rk for emacs-devel@gnu.org; Sat, 01 May 2004 07:12:26 -0400 Original-Received: from [133.82.132.2] (helo=mathmail.math.s.chiba-u.ac.jp) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BJsMu-0005Zh-Q9; Sat, 01 May 2004 07:09:17 -0400 Original-Received: from church.math.s.chiba-u.ac.jp (church [133.82.132.36]) by mathmail.math.s.chiba-u.ac.jp (Postfix) with ESMTP id 5BF681A638A; Sat, 1 May 2004 20:09:15 +0900 (JST) Original-To: John Wiegley In-Reply-To: User-Agent: Wanderlust/2.10.1 (Watching The Wheels) SEMI/1.14.5 (Awara-Onsen) FLIM/1.14.5 (Demachiyanagi) APEL/10.6 Emacs/21.3.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:22493 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:22493 >>>>> On Thu, 29 Apr 2004 15:08:39 -0700, John Wiegley said: > The crash still occurs with the patch you gave me. Thanks for your report. So the crash was not related to the event handling. Could you try the following patch? It does saving/restoring the current graphics port and device handle when drawing into an offscreen graphics world. Lack of this process might have led to an inconsistent state of a graphics port. YAMAMOTO Mitsuharu mituharu@math.s.chiba-u.ac.jp Index: src/image.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/image.c,v retrieving revision 1.8 diff -c -r1.8 image.c *** src/image.c 20 Apr 2004 22:16:33 -0000 1.8 --- src/image.c 1 May 2004 10:35:34 -0000 *************** *** 174,187 **** --- 174,192 ---- 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,199 **** --- 194,209 ---- 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,2201 **** --- 2206,2215 ---- 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,2212 **** --- 2221,2227 ---- #else EraseRect (&(ximg->portRect)); #endif + SetGWorld (old_port, old_gdh); } GraphicsImportSetGWorld (gi, ximg, NULL); GraphicsImportDraw (gi); Index: src/macterm.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/macterm.c,v retrieving revision 1.66 diff -c -r1.66 macterm.c *** src/macterm.c 24 Apr 2004 23:42:26 -0000 1.66 --- src/macterm.c 1 May 2004 10:35:42 -0000 *************** *** 383,388 **** --- 383,392 ---- 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,396 **** --- 395,402 ---- MoveTo (x1, y1); LineTo (x2, y2); UnlockPixels (GetGWorldPixMap (p)); + + SetGWorld (old_port, old_gdh); } /* Mac version of XClearArea. */ *************** *** 620,630 **** --- 626,639 ---- { 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,643 **** --- 647,653 ---- &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,684 **** --- 687,697 ---- 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,691 **** --- 699,706 ---- LockPixels (GetGWorldPixMap (p)); PaintRect (&r); /* using foreground color of gc */ UnlockPixels (GetGWorldPixMap (p)); + + SetGWorld (old_port, old_gdh); } *************** *** 724,731 **** --- 739,749 ---- 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,738 **** --- 751,758 ---- LockPixels (GetGWorldPixMap (p)); FrameRect (&r); /* using foreground color of gc */ UnlockPixels (GetGWorldPixMap (p)); + + SetGWorld (old_port, old_gdh); } *************** *** 1003,1010 **** --- 1023,1033 ---- 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,1028 **** --- 1046,1053 ---- #endif /* not TARGET_API_MAC_CARBON */ UnlockPixels (GetGWorldPixMap (dest)); UnlockPixels (GetGWorldPixMap (src)); + + SetGWorld (old_port, old_gdh); } *************** *** 1036,1043 **** --- 1061,1071 ---- 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,1063 **** --- 1086,1093 ---- UnlockPixels (GetGWorldPixMap (dest)); UnlockPixels (GetGWorldPixMap (mask)); UnlockPixels (GetGWorldPixMap (src)); + + SetGWorld (old_port, old_gdh); }