summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixEvent.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-02-18 13:31:12 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-02-18 13:31:12 (GMT)
commit2103923eee4d74b8f49cfdb91a73c3ef32baab5f (patch)
tree852b5deef1543d222d1503da61a90797406e0eea /unix/tkUnixEvent.c
parentdc4432db15fb2cbb21a3411834e283d5208945e8 (diff)
downloadtk-2103923eee4d74b8f49cfdb91a73c3ef32baab5f.zip
tk-2103923eee4d74b8f49cfdb91a73c3ef32baab5f.tar.gz
tk-2103923eee4d74b8f49cfdb91a73c3ef32baab5f.tar.bz2
Call XInitThreads once before the first Xlib call. Suggested by Brian Griffin.
Diffstat (limited to 'unix/tkUnixEvent.c')
-rw-r--r--unix/tkUnixEvent.c14
1 files changed, 13 insertions, 1 deletions
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;
}