unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
Cc: emacs-devel@gnu.org
Subject: Re: More info on sporadic OS/X crash
Date: Sat, 01 May 2004 20:09:15 +0900	[thread overview]
Message-ID: <wlhdv0h09w.wl@church.math.s.chiba-u.ac.jp> (raw)
In-Reply-To: <m2wu3y77yw.fsf@Majnun.local>

>>>>> On Thu, 29 Apr 2004 15:08:39 -0700, John Wiegley <johnw@gnu.org> 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);
  }

  reply	other threads:[~2004-05-01 11:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-15 23:15 More info on sporadic OS/X crash John Wiegley
2004-04-23 11:41 ` John Wiegley
2004-04-24  1:15   ` YAMAMOTO Mitsuharu
2004-04-25 17:49     ` Steven Tamm
2004-04-26 13:15       ` YAMAMOTO Mitsuharu
2004-04-26 16:27         ` Steven Tamm
2004-04-27  9:52           ` YAMAMOTO Mitsuharu
2004-04-27 15:24       ` Piet van Oostrum
2004-04-28  6:37         ` Eli Zaretskii
2004-04-28 11:14           ` Piet van Oostrum
2004-04-28 18:53             ` Eli Zaretskii
2004-04-29 12:10               ` Piet van Oostrum
2004-04-29 16:32                 ` Kim F. Storm
2004-04-29 22:24                   ` Steven Tamm
2004-04-29 22:25                   ` Piet van Oostrum
2004-05-01 11:32         ` YAMAMOTO Mitsuharu
2004-04-26 18:08     ` John Wiegley
2004-04-27  9:59       ` YAMAMOTO Mitsuharu
2004-04-29 22:08         ` John Wiegley
2004-05-01 11:09           ` YAMAMOTO Mitsuharu [this message]
2004-05-07  1:24             ` John Wiegley
2004-05-10  6:02             ` John Wiegley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=wlhdv0h09w.wl@church.math.s.chiba-u.ac.jp \
    --to=mituharu@math.s.chiba-u.ac.jp \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).