summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-02-25 20:33:58 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-02-25 20:33:58 (GMT)
commit54a771e501da6a4560e298e70c348ae4c3961e7f (patch)
tree12c04709beef499935e21f177476a8bf54f4bed6 /unix
parentfee86da1c91ba1bfae832ba669b288bb7bb7ddfc (diff)
downloadtk-54a771e501da6a4560e298e70c348ae4c3961e7f.zip
tk-54a771e501da6a4560e298e70c348ae4c3961e7f.tar.gz
tk-54a771e501da6a4560e298e70c348ae4c3961e7f.tar.bz2
Put mutex around XInitThreads call, making sure it is only called once.
Diffstat (limited to 'unix')
-rw-r--r--unix/tkUnixEvent.c15
1 files 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