~metalune/dmenu

f5036b90efd9423d805923a0bc73cd54e30e72ab — Hiltjo Posthuma 2 years ago 153aaf8
fix crash when XOpenIM returns NULL

for example when IME variables are set, but the program is not started (yet).
1 files changed, 11 insertions(+), 2 deletions(-)

M dmenu.c
M dmenu.c => dmenu.c +11 -2
@@ 664,8 664,17 @@ setup(void)
	                    CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
	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,
	                XNClientWindow, win, XNFocusWindow, win, NULL);