RE: [ROOT] Multithreaded GUI, TRootEmbeddedCanvas

From: marc.hemberger@realtech.de
Date: Thu Aug 30 2001 - 10:35:28 MEST


Hi,

X11 has a library call XInitThreads(), which is in some X11 libraries really
doing something ;-) Must be the very first call before any call to the X
library. May be this helps. This is in fact done by ROOT, as we do it before
creating the display.

In ./x11/src/GX11Gui.cxx we introduced:

Int_t TGX11::OpenDisplay(const char *dpyName)
{                                        
...
#ifdef _REENTRANT
      // very first call before any X-call !!
      if (!XInitThreads())
         Warning("OpenDisplay", "system has no X11 thread support");
#endif            
...
}

Greetings,

Marc

-> -----Original Message-----
-> From: Victor Perevoztchikov [mailto:perev@bnl.gov]
-> Sent: Monday, August 20, 2001 3:53 PM
-> To: Thomas Bretz
-> Cc: roottalk@pcroot.cern.ch
-> Subject: Re: [ROOT] Multithreaded GUI, TRootEmbeddedCanvas
-> 
-> 
-> Hi Thomas,
-> 
-> TCanvas::Update has defence from non thread safe X11. 
-> 
->  void TCanvas::Update()
-> {
->    if (gThreadXAR) {  //<========================= This is defence
->       void *arr[2];
->       arr[1] = this;
->       if ((*gThreadXAR)("CUPD", 2, arr, NULL)) return;
->    }
->    if (!IsBatch()) FeedbackMode(kFALSE);      // Goto double 
-> buffer mode
->    PaintModified();           // Repaint all modified pad's
->    Flush();                   // Copy all pad pixmaps to the screen
->    SetCursor(kCross);
-> }
-> 
-> But may be due to your own TApplication the gThreadXAR is zero.
-> Check it please.
-> 
-> Victor
-> 
-> Thomas Bretz wrote:
-> > 
-> > Hello,
-> > 
-> > I have some trouble with the following:
-> > 
-> > I have a class derived from TApplication. In its 
-> constructor I create a
-> > GUI (a class derived from TMainFrame, which creates two 
-> instances of a
-> > class derived from RootEmbeddedCanvas) and a thread. The 
-> thread calls
-> > GetCanvas()->Modified() and GetCanvas()->Update() for both embedded
-> > canvases after updating its contents in a loop.
-> > In most cases I get some X11 error about invalid Pixmaps. 
-> I guess it is
-> > because TApplication::Run() and the GUI-Update-Loop are running in
-> > different threads. How can I work around this? (Maybe I could use
-> > timers, but for me it is important to run the updating 
-> thread with less
-> > priority than the main thread).
-> > 
-> > Can somebody help me?
-> > 
-> > Thanks,
-> > Thomas.
-> 
-> -- 
-> Victor M. Perevoztchikov   perev@bnl.gov  perev@vxcern.cern.ch       
-> Brookhaven National Laboratory MS 510A PO Box 5000 Upton NY 
-> 11973-5000
-> tel office : 631-344-7894; fax 631-344-4206; home 631-345-2690
-> 



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:58 MET