fix crash when XOpenIM returns NULL

for example when IME variables are set, but the program is not started (yet).
This commit is contained in:
Hiltjo Posthuma 2019-02-12 19:10:43 +01:00 committed by Justin Ludwig
parent d6351cf625
commit c10954a12a

13
dmenu.c
View File

@ -857,8 +857,17 @@ setup(void)
CWOverrideRedirect | CWBackPixel | CWColormap | CWEventMask | CWBorderPixel, &swa); CWOverrideRedirect | CWBackPixel | CWColormap | CWEventMask | CWBorderPixel, &swa);
XSetClassHint(dpy, win, &ch); XSetClassHint(dpy, win, &ch);
/* open input methods */
xim = XOpenIM(dpy, NULL, NULL, NULL); /* input methods */
if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) {
XSetLocaleModifiers("@im=local");
if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) {
XSetLocaleModifiers("@im=");
if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
die("XOpenIM failed. Could not open input device.\n");
}
}
xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
XNClientWindow, win, XNFocusWindow, win, NULL); XNClientWindow, win, XNFocusWindow, win, NULL);