From 54a771e501da6a4560e298e70c348ae4c3961e7f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 25 Feb 2013 20:33:58 +0000 Subject: Put mutex around XInitThreads call, making sure it is only called once. --- unix/tkUnixEvent.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c index 6268b25..c540157 100644 --- a/unix/tkUnixEvent.c +++ b/unix/tkUnixEvent.c @@ -119,13 +119,18 @@ TkpOpenDisplay( Display *display; #ifdef TCL_THREADS static int xinited = 0; + TCL_DECLARE_MUTEX(xinitMutex); 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; + Tcl_MutexLock(&xinitMutex); + 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; + } + Tcl_MutexUnlock(&xinitMutex); } #endif -- cgit v0.12