emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] trunk r116687: * xterm.c (xim_initialize): Always pass a c


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r116687: * xterm.c (xim_initialize): Always pass a copy of resource name
Date: Thu, 06 Mar 2014 11:18:39 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 116687
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Thu 2014-03-06 15:18:22 +0400
message:
  * xterm.c (xim_initialize): Always pass a copy of resource name
  to XRegisterIMInstantiateCallback and eassert whether return
  value is True.  Passing copy is important because Xlib doesn't
  make its own copy and resource name argument usually points to
  SSDATA (Vx_resource_name), which may be changed from Lisp.
  (xim_close_display): For XUnregisterIMInstantiateCallback,
  always eassert return value and pass exactly the same values
  as were used for XRegisterIMInstantiateCallback.  Otherwise
  XUnregisterIMInstantiateCallback will always fail.  See Xlib
  sources to check why if you are interested.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/xterm.c                    xterm.c-20091113204419-o5vbwnq5f7feedwu-244
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2014-03-05 13:50:48 +0000
+++ b/src/ChangeLog     2014-03-06 11:18:22 +0000
@@ -1,3 +1,16 @@
+2014-03-06  Dmitry Antipov  <address@hidden>
+
+       * xterm.c (xim_initialize): Always pass a copy of resource name
+       to XRegisterIMInstantiateCallback and eassert whether return
+       value is True.  Passing copy is important because Xlib doesn't
+       make its own copy and resource name argument usually points to
+       SSDATA (Vx_resource_name), which may be changed from Lisp.
+       (xim_close_display): For XUnregisterIMInstantiateCallback,
+       always eassert return value and pass exactly the same values
+       as were used for XRegisterIMInstantiateCallback.  Otherwise
+       XUnregisterIMInstantiateCallback will always fail.  See Xlib
+       sources to check why if you are interested.
+
 2014-03-05  Martin Rudalics  <address@hidden>
 
        * dispnew.c (change_frame_size_1): Add new_lines instead of

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2014-03-04 11:02:36 +0000
+++ b/src/xterm.c       2014-03-06 11:18:22 +0000
@@ -7955,17 +7955,18 @@
     {
 #ifdef HAVE_X11R6_XIM
       struct xim_inst_t *xim_inst = xmalloc (sizeof *xim_inst);
+      Bool ret;
 
       dpyinfo->xim_callback_data = xim_inst;
       xim_inst->dpyinfo = dpyinfo;
       xim_inst->resource_name = xstrdup (resource_name);
-      XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
-                                     resource_name, emacs_class,
-                                     xim_instantiate_callback,
-                                     /* This is XPointer in XFree86
-                                        but (XPointer *) on Tru64, at
-                                        least, hence the configure test.  */
-                                     (XRegisterIMInstantiateCallback_arg6) 
xim_inst);
+      ret = XRegisterIMInstantiateCallback
+       (dpyinfo->display, dpyinfo->xrdb, xim_inst->resource_name,
+        emacs_class, xim_instantiate_callback,
+        /* This is XPointer in XFree86 but (XPointer *)
+           on Tru64, at least, hence the configure test.  */
+        (XRegisterIMInstantiateCallback_arg6) xim_inst);
+      eassert (ret == True);
 #else /* not HAVE_X11R6_XIM */
       xim_open_dpy (dpyinfo, resource_name);
 #endif /* not HAVE_X11R6_XIM */
@@ -7983,12 +7984,18 @@
   if (use_xim)
     {
 #ifdef HAVE_X11R6_XIM
+      struct xim_inst_t *xim_inst = dpyinfo->xim_callback_data;
+      
       if (dpyinfo->display)
-       XUnregisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
-                                         NULL, emacs_class,
-                                         xim_instantiate_callback, NULL);
-      xfree (dpyinfo->xim_callback_data->resource_name);
-      xfree (dpyinfo->xim_callback_data);
+       {
+         Bool ret = XUnregisterIMInstantiateCallback
+           (dpyinfo->display, dpyinfo->xrdb, xim_inst->resource_name,
+            emacs_class, xim_instantiate_callback,
+            (XRegisterIMInstantiateCallback_arg6) xim_inst);
+         eassert (ret == True);
+       }
+      xfree (xim_inst->resource_name);
+      xfree (xim_inst);
 #endif /* HAVE_X11R6_XIM */
       if (dpyinfo->display)
        XCloseIM (dpyinfo->xim);


reply via email to

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