From 945a7876ada7263de3ded05fde6c8060a8775559 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Wed, 10 Mar 2021 09:27:27 -0500 Subject: [PATCH] Realized what the underlying cause of crashing on undefined "dpy" was and fixed it at the root of the problem. --- events.c | 3 --- tclxcircuit.c | 7 +++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/events.c b/events.c index 80b8e4a..1f846e6 100644 --- a/events.c +++ b/events.c @@ -2399,9 +2399,6 @@ int getkeysignature(XKeyEvent *event) if (event->keycode == 0 && event->state == 0) return -1; #endif - /* XLookupString() will fail if the display is not valid */ - if (dpy == NULL) return -1; - XLookupString(event, _STR, 150, &keypressed, NULL); /* Ignore Shift, Control, Caps Lock, and Meta (Alt) keys */ diff --git a/tclxcircuit.c b/tclxcircuit.c index a487c02..d6b42bd 100644 --- a/tclxcircuit.c +++ b/tclxcircuit.c @@ -9880,7 +9880,7 @@ XCWindowData *GUI_init(int objc, Tcl_Obj *CONST objv[]) { Tk_Window tkwind, tktop, tkdraw, tksb; Tk_Window wsymb, wschema, corner; - int i, locobjc, done = 1; + int i, locobjc, done = 1, first; XGCValues values; Window win; popupstruct *fileliststruct; @@ -10046,6 +10046,9 @@ XCWindowData *GUI_init(int objc, Tcl_Obj *CONST objv[]) win = Tk_WindowId(tkwind); Tk_MapWindow(newwin->area); + first = (dpy == NULL) ? 1 : 0; + dpy = Tk_Display(tkwind); + if (!done) { while (!done) Tcl_DoOneEvent(0); Tk_DeleteEventHandler(newwin->area, @@ -10059,7 +10062,7 @@ XCWindowData *GUI_init(int objc, Tcl_Obj *CONST objv[]) /* Things to set once only */ - if (dpy == NULL) { + if (first == 1) { dpy = Tk_Display(tkwind); cmap = Tk_Colormap(tkwind); // (The following may be required on some systems where -- 2.11.4.GIT