Index: trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc	(revision 2488)
+++ trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc	(revision 2491)
@@ -107,4 +107,5 @@
 
 // ------------ Workaround for a non working TGTextView::Search -------------
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,02,05)
 class MGTextView : public TGTextView
 {
@@ -165,4 +166,7 @@
     }
 };
+#else
+#define MGTextView TGTextView
+#endif
 // --------------------------------------------------------------------------
 
@@ -566,4 +570,5 @@
 
     fFont = gVirtualX->LoadQueryFont("7x13bold");
+    fMutex = new TMutex;
 
     //
@@ -666,4 +671,9 @@
     if (fFont)
         gVirtualX->DeleteFont(fFont);
+
+    //
+    // Delete mutex
+    //
+    delete fMutex;
 }
 
@@ -820,7 +830,7 @@
 
     // layout and map new tab
-    Layout();
-    MapSubwindows();
-    Layout();
+    Layout();          // seems to layout the TGCompositeFrame
+    MapSubwindows();   // maps the TGCompositeFrame
+    Layout();          // layout the embedded canvas in the frame
 
     // display new tab in the main frame
@@ -864,8 +874,4 @@
     // the main thread.
     //
-    // NOTE: Maybe there is still need to make sure, that only
-    //       one thread can update the canvas by calling UpdateTab
-    //       at the same time. Could be done by a TMutex.
-    //
     if (gThreadXAR)
     {
@@ -881,5 +887,15 @@
     }
 
-#if ROOT_VERSION_CODE < ROOT_VERSION(3,10,01)
+    //
+    // Secure calls to update the tabs against itself, at least
+    // c->Paint() or c->Flush() may crash X (bad drawable).
+    // This makes sure, that a X call is not interuppted by
+    // another X-call which was started from an gui interrrupt
+    // in the same thread
+    //
+    if (mutex->TryLock()==13)
+        return;
+
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,10,02)
     TPad *padsav = (TPad*)gPad;
     if (!gPad)
@@ -897,5 +913,5 @@
     c->Flush();                   // Copy all pad pixmaps to the screen
 
-#if ROOT_VERSION_CODE < ROOT_VERSION(3,10,01)
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,10,02)
     if (padsav)
         padsav->cd();
@@ -903,4 +919,5 @@
         gPad=NULL;
 #endif
+
     //c->SetCursor(kCross);
 
@@ -909,4 +926,6 @@
     //c->Update();
     //c->Paint();
+
+    mutex->UnLock();
 }
 
@@ -979,13 +998,14 @@
 
     fTab->RemoveTab(i);
+    fTab->SetTab(0);
+
+    // Looks strange...
+    // const Int_t n = fTab->GetNumberOfTabs();
+    // fTab->SetTab(i<=n-1 ? i : i-1);
 
     // layout and map new tab
-#if ROOT_VERSION_CODE < ROOT_VERSION(3,03,00)
-    MapSubwindows();
-    Layout();
-#else
-    Layout();
-    MapSubwindows();
-#endif
+    Layout();          // seems to layout the TGCompositeFrame
+    MapSubwindows();   // maps the TGCompositeFrame
+    Layout();          // layout the embedded canvas in the frame
 
     // display new tab in the main frame
@@ -1858,13 +1878,5 @@
 
     ps.Close();
-
-    if (num<0)
-        *fLog << inf << " - ";
-
-    SetStatusLine2("Updating Postscript header...");
-    *fLog << inf << "Updating Postscript header..." << flush;
     UpdatePSHeader(name);
-    *fLog << inf << "done." << endl;
-
 
     gVirtualPS = psave;
Index: trunk/MagicSoft/Mars/mmain/MStatusDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mmain/MStatusDisplay.h	(revision 2488)
+++ trunk/MagicSoft/Mars/mmain/MStatusDisplay.h	(revision 2491)
@@ -20,4 +20,5 @@
 class TPad;
 class TTimer;
+class TMutex;
 class TCanvas;
 
@@ -64,5 +65,6 @@
     TGLayoutHints    *fLayCanvas;
 
-    TTimer fTimer;
+    TTimer  fTimer;
+    TMutex *fMutex;
 
     TGStatusBar *fStatusBar;
@@ -122,6 +124,6 @@
 
      void StartUpdate(Int_t millisec=-1);
-     void StopUpdate();                  
-     void SetUpdateTime(Long_t t);       
+     void StopUpdate();
+     void SetUpdateTime(Long_t t);
 
      void SetProgressBarPosition(Float_t p);
