Overview
| Artifact ID: | 0accb979cb8e0227e778175c54a1fa6c573fc04c |
|---|---|
| Ticket: | 570902ffffffffffffffffffffffffffffffffff |
| Date: | 2002-06-19 09:29:33 |
| User: | mdejong |
| Artifact Attached: | db9986ce4588aaa2efec85fa1ec0da7995ef2cc9 |
| Filename: | im.c |
| Description: | Minimal test case for XCloseIM bug |
Content:
#include <X11/Xlib.h>
#include <stdlib.h>
#include <locale.h>
int main() {
Display *d;
int screen;
Window window;
XIM im;
XIC ic;
if (setlocale(LC_CTYPE, "") == NULL)
exit(1);
if (! XSupportsLocale() )
exit(2);
d = XOpenDisplay(":0.0");
if (d == NULL)
exit(3);
screen = DefaultScreen(d);
window = XCreateSimpleWindow(d, RootWindow(d, screen),
0, 0, 200, 200, 2,
BlackPixel(d, screen),
WhitePixel(d, screen));
im = XOpenIM(d, NULL, NULL, NULL);
if (im == NULL)
exit(4);
if( (ic = XCreateIC(im, XNInputStyle,
XIMPreeditNothing | XIMStatusNothing,
XNClientWindow, window, NULL)) == NULL )
exit(5);
/*
The XCloseIM method can free the same memory twice
because of a bug in the close method for a specific
input context. This fix is to NULL out the
im->core.ic_chain member after freeing the elements
of the queue. This should be done by X, but we
can avoid the bug by calling XDestroyIC ourselves.
*/
/*XDestroyIC(ic);*/
XCloseIM(im);
XCloseDisplay(d);
}
