From 2103923eee4d74b8f49cfdb91a73c3ef32baab5f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 18 Feb 2013 13:31:12 +0000 Subject: Call XInitThreads once before the first Xlib call. Suggested by Brian Griffin. --- ChangeLog | 5 +++++ unix/tkUnixEvent.c | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 09f0acd..75a617f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-02-18 Jan Nijtmans + + * unix/tkUnixEvent.c: Call XInitThreads once before the + first Xlib call. Suggested by Brian Griffin. + 2013-01-14 Jan Nijtmans * win/tcl.m4: More flexible search for win32 tclConfig.sh, diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c index 4d0ccfa..6268b25 100644 --- a/unix/tkUnixEvent.c +++ b/unix/tkUnixEvent.c @@ -116,8 +116,20 @@ TkpOpenDisplay( const char *displayNameStr) { TkDisplay *dispPtr; - Display *display = XOpenDisplay(displayNameStr); + Display *display; +#ifdef TCL_THREADS + static int xinited = 0; + + if (!xinited) { + /* Necessary for threaded apps, of no consequence otherwise */ + /* need only be called once, but must be called before *any* */ + /* Xlib call is made. */ + XInitThreads(); + xinited = 1; + } +#endif + display = XOpenDisplay(displayNameStr); if (display == NULL) { return NULL; } -- cgit v0.12