emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] XCloseDisplay already calls XrmDestroyDatabase


From: YAMAMOTO Mitsuharu
Subject: Re: [PATCH] XCloseDisplay already calls XrmDestroyDatabase
Date: Mon, 18 May 2009 17:09:08 +0900
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.8 (Shijō) APEL/10.6 Emacs/22.3 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI)

>>>>> On Sun, 17 May 2009 17:40:50 -0400, Stefan Monnier <address@hidden> said:

>>> If we remove the XrmDestroyDatabase call unconditionally, then it
>>> causes a memory leak when used with a newer libX11.  But that would
>>> be better than crashing when used with an older one.

>> Or maybe we can dissociate the resource database from the display
>> before closing it.

>> #ifdef HAVE_XRMSETDATABASE
>> XrmSetDatabase (dpyinfo->display, NULL);
>> #else
>> dpyinfo->display->db = NULL;
>> #endif

>> Then we can ignore the difference of libX11 at least for normal close.

> Sounds OK as well.

Here is a patch.  If it's OK, I'd like to install it before the next
pretest.

                                     YAMAMOTO Mitsuharu
                                address@hidden

Index: src/xterm.c
===================================================================
RCS file: /sources/emacs/emacs/src/xterm.c,v
retrieving revision 1.1025
diff -c -p -r1.1025 xterm.c
*** src/xterm.c 2 May 2009 20:16:58 -0000       1.1025
--- src/xterm.c 18 May 2009 08:00:51 -0000
*************** x_delete_display (dpyinfo)
*** 10613,10625 ****
          tail->next = tail->next->next;
      }
  
-   /* Xt and GTK do this themselves.  */
- #if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
- #ifndef AIX           /* On AIX, XCloseDisplay calls this.  */
-   XrmDestroyDatabase (dpyinfo->xrdb);
- #endif
- #endif
- 
    xfree (dpyinfo->x_id_name);
    xfree (dpyinfo->x_dnd_atoms);
    xfree (dpyinfo->color_cells);
--- 10613,10618 ----
*************** x_delete_terminal (struct terminal *term
*** 10740,10745 ****
--- 10733,10752 ----
        x_destroy_all_bitmaps (dpyinfo);
        XSetCloseDownMode (dpyinfo->display, DestroyAll);
  
+       /* Whether or not XCloseDisplay destroys the associated resource
+        database depends on the version of libX11.  To avoid both
+        crash and memory leak, we dissociate the database from the
+        display and then destroy dpyinfo->xrdb ourselves.  */
+ #ifdef HAVE_XRMSETDATABASE
+       XrmSetDatabase (dpyinfo->display, NULL);
+ #else
+       dpyinfo->display->db = NULL;
+ #endif
+       /* We used to call XrmDestroyDatabase from x_delete_display, but
+        some older versions of libX11 crash if we call it after
+        closing all the displays.  */
+       XrmDestroyDatabase (dpyinfo->xrdb);
+ 
  #ifdef USE_GTK
        xg_display_close (dpyinfo->display);
  #else




reply via email to

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