Index: trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 2556)
+++ trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 2563)
@@ -560,5 +560,5 @@
 //
 MStatusDisplay::MStatusDisplay(Long_t t)
-: TGMainFrame(NULL, 1, 1), fTab(NULL), fTimer(this, t, kTRUE), fStatus(kLoopNone), fLog(&gLog), fLogIdx(-1), fLogTimer(this, 250, kTRUE), fLogBox(NULL), fIsLocked(0)
+: TGMainFrame(NULL, 1, 1), fLog(&gLog), fTab(NULL), fTimer(this, t, kTRUE), fStatus(kLoopNone), fLogIdx(-1), fLogTimer(this, 250, kTRUE), fLogBox(NULL), fIsLocked(0)
 {
     // p==NULL means: Take gClient->GetRoot() if not in batch mode
@@ -587,11 +587,4 @@
     fList = new MGList;
     fList->SetOwner();
-
-    //
-    // set the smallest and biggest size of the Main frame
-    // and move it to its appearance position
-    SetWMSizeHints(570, 480, 1280, 980, 1, 1);
-    Move(rand()%100+50, rand()%100+50);
-    Resize(570, 480);
 
     //
@@ -612,4 +605,10 @@
         AddStatusBar();
     }
+
+    //
+    // set the smallest and biggest size of the Main frame
+    // and move it to its appearance position
+    SetWMSizeHints(570, 480, 1280, 980, 1, 1);
+    MoveResize(rand()%100+570, rand()%100+480, 570, 480);
 
     //
@@ -1052,4 +1051,10 @@
  */
 
+void MStatusDisplay::Reset()
+{
+    for (int i=fTab->GetNumberOfTabs()-1; i>0; i--)
+        RemoveTab(i);
+}
+
 // --------------------------------------------------------------------------
 //
@@ -1077,6 +1082,5 @@
 
     case kFileReset:
-        for (int i=fTab->GetNumberOfTabs()-1; i>0; i--)
-            RemoveTab(i);
+        Reset();
         return kTRUE;
         /*
@@ -1217,7 +1221,7 @@
     switch (submsg)
     {
-    case kCM_MENU:
+    case kCM_MENU: // 1
         return ProcessMessageCommandMenu(mp1); // mp2=userdata
-    case kCM_TAB:
+    case kCM_TAB:  // 8
         /*
          for (int i=0; i<fTab->GetNumberOfTabs(); i++)
@@ -1238,25 +1242,25 @@
         return kTRUE;
 #ifdef DEBUG
-    case kCM_MENUSELECT:
+    case kCM_MENUSELECT: // 2
         cout << "Command-Menuselect #" << mp1 << " (UserData=" << (void*)mp2 << ")" << endl;
         return kTRUE;
 
-    case kCM_BUTTON:
+    case kCM_BUTTON: // 3
         cout << "Command-Button." << endl;
         return kTRUE;
 
-    case kCM_CHECKBUTTON:
+    case kCM_CHECKBUTTON: // 4
         cout << "Command-CheckButton." << endl;
         return kTRUE;
 
-    case kCM_RADIOBUTTON:
+    case kCM_RADIOBUTTON: // 5
         cout << "Command-RadioButton." << endl;
         return kTRUE;
 
-    case kCM_LISTBOX:
+    case kCM_LISTBOX: // 6
         cout << "Command-Listbox #" << mp1 << " (LineId #" << mp2 << ")" << endl;
         return kTRUE;
 
-    case kCM_COMBOBOX:
+    case kCM_COMBOBOX: // 7
         cout << "Command-ComboBox." << endl;
         return kTRUE;
@@ -1351,15 +1355,17 @@
 {
     // Can be found in WidgetMessageTypes.h
+#ifdef DEBUG
     cout << "Msg: " << GET_MSG(msg) << " Submsg:" << GET_SUBMSG(msg);
     cout << " Mp1=" << mp1 << " Mp2=" << mp2 << endl;
+#endif
     switch (GET_MSG(msg))
     {
-    case kC_COMMAND:
+    case kC_COMMAND:  // 1
         return ProcessMessageCommand(GET_SUBMSG(msg), mp1, mp2);
 
-    case kC_TEXTVIEW:
+    case kC_TEXTVIEW: // 9
         return ProcessMessageTextview(GET_SUBMSG(msg), mp1, mp2);
 
-    case kC_USER:
+    case kC_USER:     // 1001
         return ProcessMessageUser(GET_SUBMSG(msg), mp1, mp2);
     }
@@ -1387,12 +1393,17 @@
     gLog << dbg << "MStatusDisplay is on heap: " << (int)IsOnHeap() << endl;
 
-    if (TestBit(kExitLoopOnExit))
+    if (TestBit(kExitLoopOnExit) || TestBit(kExitLoopOnClose))
+    {
+        gLog << dbg << "CloseWindow() calling ExitLoop." << endl;
         gSystem->ExitLoop();
-    if (TestBit(kExitLoopOnClose))
-        gSystem->ExitLoop();
+    }
 
     if (fIsLocked<=0 && IsOnHeap())
+    {
+        gLog << dbg << "delete MStatusDisplay;" << endl;
         delete this;
+    }
     fStatus = kFileExit;
+    gLog << dbg << "MStatusDisplay.fStatus=kFileExit;" << endl;
 }
 
@@ -2117,14 +2128,14 @@
      */
 
-    //Bool_t wchanged = w!=GetWidth();
+    Bool_t wchanged = w!=GetWidth();
     Bool_t hchanged = h!=GetHeight();
-    /*
+
     if (!wchanged && !hchanged)
     {
         Layout();
         // FIXME: Make sure that this doesn't result in endless loops.
-        // return kTRUE;
-    }
-    */
+        return kTRUE;
+    }
+
 
     if (GetWidth()==1 && GetHeight()==1)
@@ -2149,4 +2160,12 @@
 Bool_t MStatusDisplay::HandleEvent(Event_t *event)
 {
+#if ROOT_VERSION_CODE == ROOT_VERSION(3,05,07)
+    // Strange... crashes on the LP machines...
+    if (event->fType==kClientMessage)
+        if (event->fHandle == gROOT_MESSAGE)
+            if (event->fUser[0]==264 && event->fUser[1] == 0 && event->fUser[2]==0)
+                return kTRUE;
+#endif
+
     Bool_t rc = TGMainFrame::HandleEvent(event);
 
Index: trunk/MagicSoft/Mars/mbase/MStatusDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mbase/MStatusDisplay.h	(revision 2556)
+++ trunk/MagicSoft/Mars/mbase/MStatusDisplay.h	(revision 2563)
@@ -56,9 +56,11 @@
     enum
     {
-        kExitLoopOnExit  = BIT(14),
-        kExitLoopOnClose = BIT(15)
+        // TGMainFrame::kDontCallClose = BIT(14)
+        kExitLoopOnExit  = BIT(15),
+        kExitLoopOnClose = BIT(16)
      };
 
 protected:
+    MLog             *fLog;
     MGList           *fList;
     TGCompositeFrame *fUserFrame;
@@ -80,5 +82,4 @@
     TString fPrinter;
 
-    MLog *fLog;
     Int_t fLogIdx;
     TTimer fLogTimer;
@@ -179,4 +180,6 @@
      void UnLock() { if (fIsLocked>0) fIsLocked--; }
 
+     void Reset();
+
      Bool_t CheckTabForCanvas(int num) const;
 
