On Wednesday, April 29, 2009 at 21:58:03 (+0100) Andrew Ross writes: > Further testing has shown that I can get rid of the segmentation fault by > removing the call to XInitThreads in the OpenXwin function in xwin.c. > According to the Xlib documentation: > > "The XInitThreads() function initializes Xlib support for concurrent > threads. This function must be the first Xlib function a multi-threaded > program calls, and it must complete before any other Xlib call is made. > This function returns a nonzero status if initialization was successful; > otherwise, it returns zero. On systems that do not support threads, this > function always returns zero. > > It is only necessary to call this function if multiple threads might use > Xlib concurrently. If all calls to Xlib functions are protected by some > other access mechanism (for example, a mutual exclusion lock in a toolkit > or through explicit client programming), Xlib thread initialization is > not required. It is recommended that single-threaded programs not call > this function." > .. > In particular, with the tk support there may be other Xlib calls > elsewhere which are not protected. It is also probable that > XInitThreads is not actually the first Xlib call in this case.
It is not. In plframe.c the window is created by: new = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp), argv[1], (char *) NULL); which ultimately terminates in a call to XCreateWindow(). From the Tk generic/tkWindow.c -- * tkWindow.c -- * * This file provides basic window-manipulation procedures, * which are equivalent to procedures in Xlib (and even * invoke them) but also maintain the local Tk_Window * structure. The partial initialization of the xwin driver the plframe widget does after that may not require the window to actually already exist -- I don't see any explicit dependence, although it's been too long for me to remember if I ever tried doing the two ops in reverse order. You might want to give this a try. I.e. move the code /* Partially initialize X driver. */ pllib_init(); plsdev("xwin"); pllib_devinit(); plP_esc(PLESC_DEVINIT, NULL); above the call to Tk_CreateWindowFromPath(). -- Maurice LeBrun ------------------------------------------------------------------------------ Register Now & Save for Velocity, the Web Performance & Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance & Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf _______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel