diff options
author | Dmitry Antipov <dmantipov@yandex.ru> | 2014-03-06 15:18:22 +0400 |
---|---|---|
committer | Dmitry Antipov <dmantipov@yandex.ru> | 2014-03-06 15:18:22 +0400 |
commit | 12e852a208f2035094b46999e92afa8e3366748b (patch) | |
tree | 4843fd877d76169e571bb18ce4b43a812601ba34 /src | |
parent | f65ba1005b499a7fb77c77652f37338277f06616 (diff) | |
download | emacs-12e852a208f2035094b46999e92afa8e3366748b.tar.gz |
* 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.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 13 | ||||
-rw-r--r-- | src/xterm.c | 31 |
2 files changed, 32 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 29b6078b037..8f9d7f555a3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2014-03-06 Dmitry Antipov <dmantipov@yandex.ru> + + * 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 <rudalics@gmx.at> * dispnew.c (change_frame_size_1): Add new_lines instead of diff --git a/src/xterm.c b/src/xterm.c index 71b5126f340..bf5456b5f8b 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -7955,17 +7955,18 @@ xim_initialize (struct x_display_info *dpyinfo, char *resource_name) { #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 @@ xim_close_dpy (struct x_display_info *dpyinfo) 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); |