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)
commit1a78d8ff7f80e8f03555b07c633b2377d392538f (patch)
tree12c04709beef499935e21f177476a8bf54f4bed6 /unix
parentf77016087cb69115bed89d614535c7f86d085ac1 (diff)
downloadtk-1a78d8ff7f80e8f03555b07c633b2377d392538f.zip
tk-1a78d8ff7f80e8f03555b07c633b2377d392538f.tar.gz
tk-1a78d8ff7f80e8f03555b07c633b2377d392538f.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