emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More info on sporadic OS/X crash


From: YAMAMOTO Mitsuharu
Subject: Re: More info on sporadic OS/X crash
Date: Sat, 01 May 2004 20:09:15 +0900
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)

>>>>> On Thu, 29 Apr 2004 15:08:39 -0700, John Wiegley <address@hidden> 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
                                address@hidden

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 via email to

[Prev in Thread] Current Thread [Next in Thread]