Index: trunk/MagicSoft/Mars/Changelog
===================================================================
--- trunk/MagicSoft/Mars/Changelog	(revision 2490)
+++ trunk/MagicSoft/Mars/Changelog	(revision 2491)
@@ -1,5 +1,5 @@
                                                  -*-*- END OF LINE -*-*-
 
-  2003/11/10: Nicola Galante
+  2003/11/10: Thomas Bretz
   
    * macros/dohtml.C:
@@ -45,4 +45,29 @@
      - removed obsolete include of iosfwd
 
+   * Makefile:
+     - changed makedepend line size
+     - renamed shared object from mars.so to libmars.so
+     - moved shared object from lib-directory to mars root directory
+     - make all executables load the shared object instead of statically 
+       linking
+     
+   * Makefile.conf.darwin, Makefile.conf.linux, Makefile.conf.linux-gnu,
+     Makefile.conf.osf1, Makefile.conf.osf5.1:
+     - removed obsolete SUBDIRS in MARS_LIB
+     
+   * mars.cc:
+     - do not show logo if command line arguments are wrong
+
+   * macros/rootlogon.C:
+     - load libmars.so instead of lib/mars.so
+     - added mreflector to include path
+     
+   * mmain/MStatusDisplay.[h,cc]:
+     - secure UpdateTab with a TMutex
+     - do not use MGTextView for root versions >= 3.02.05
+     - fixed a crash when all tabs where deleted, no tab was active
+       anymore
+     - show when updating postscript header
+
 
   
@@ -50,9 +75,11 @@
 
    * mhistmc/MHMcTriggerLvl2.[cc,h]:
-     - Changed binning of histograms fHistLutPseudoSize, fHistLutPseudoSizeNorm,
-       fHistSizeBiggerCell, fHistSizeBiggerCellNorm to fix an overflow bug
-     - In method GetHistByName(const TString name): changed the class of the returned object,
-       now it returns a (TObject *), no more a (TH1F *), in order to return
-       either (TH1 *) than (TH2 *); changed the order by which it checks the name of the
+     - Changed binning of histograms fHistLutPseudoSize, 
+       fHistLutPseudoSizeNorm, fHistSizeBiggerCell, 
+       fHistSizeBiggerCellNorm to fix an overflow bug
+     - In method GetHistByName(const TString name): changed the class 
+       of the returned object, now it returns a (TObject *), no more 
+       a (TH1F *), in order to return either (TH1 *) than (TH2 *); 
+       changed the order by which it checks the name of the
        histogram in order to fix a bug in the lexing
 
Index: trunk/MagicSoft/Mars/Makefile
===================================================================
--- trunk/MagicSoft/Mars/Makefile	(revision 2490)
+++ trunk/MagicSoft/Mars/Makefile	(revision 2491)
@@ -20,6 +20,7 @@
 #
 
-PROGRAMS = readraw merpp star mars
-SOLIB    = mars.so
+#PROGRAMS = readraw merpp mars test mona status
+PROGRAMS = readraw merpp mars
+SOLIB    = libmars.so
 CINT     = M
 
@@ -37,11 +38,13 @@
 SUBDIRS = mbase \
 	  mmain \
+          mfilter \
+          mdata \
+          mhist \
+          manalysis \
           mfileio \
           mreflector \
-          mhist \
           mdatacheck \
           mgeom \
           mimage \
-          manalysis \
           mmontecarlo \
           mmc \
@@ -49,9 +52,10 @@
           mgui \
           mranforest \
-          mdata \
           mhistmc \
-          mfilter \
           mtools
 
+#          monline \
+
+#LIBRARIES = $(SUBDIRS:%=lib/lib%.a)
 LIBRARIES = $(SUBDIRS:=.a)
 MRPROPERS = $(SUBDIRS:=.mrproper)
@@ -62,5 +66,5 @@
 .SUFFIXES: .c .cc .h .o 
 
-SRCFILES = 
+SRCFILES =
 
 SRCS    = $(SRCFILES)
@@ -84,9 +88,8 @@
 	@echo " Linking $(SOLIB) ..."
 	$(CXX) $(DYNLIB) $(CXXFLAGS) $(SUBDIRS:=/*.o) $(ROOTGLIBS) -o $@
-	mv mars.so lib
 
-$(PROGRAMS): $(LIBRARIES) $(OBJS) $(HEADERS) MCint.o $(PROGRAMS:=.o) 
+$(PROGRAMS): $(SOLIB) $(PROGRAMS:=.o)
 	@echo " Linking $@ ..." 
-	$(CXX) $(CXXFLAGS) $@.o $(OBJS) $(MARS_LIB) MCint.o $(ROOTGLIBS) -o $@
+	$(CXX) $(CXXFLAGS) $(ROOTGLIBS) $(SOLIB) $@.o $(MARS_LIB) -o $@
 
 #
@@ -114,5 +117,6 @@
 $(LIBRARIES):
 	@echo " Creating lib$@:"
-	(cd $*; make; cd ..; mv $*/$@ lib/lib$@) 
+	(cd $*; make; cd ..; mv $*/$@ lib/lib$@)
+#	(cd $(@:lib/lib%.a=%); make; cd ..; mv $(@:lib/lib%.a=%)/$(@:lib/lib%=%) $@)
 
 $(MRPROPERS):
@@ -137,14 +141,14 @@
 	@echo "Making tar-file"
 	@root -b -q -l -n tar.C
-#	@tar cvf ../mars.tar --exclude=Root .roo trc *
+#	@tar cvf ../mars.tar --exclude=Root .rootrc *
 #	@gzip -9 ../mars.tar
 
-depend:
+Makefile.depend:
 	(! find ./ Makefile.depend -maxdepth 1 -empty 2> /dev/null && \
 	echo " Generating dependancies into Makefile.depend" && \
-	makedepend -- $(INCLUDES) -- $(PROGRAMS:=.cc) $(SRCS) $(SUBDIRS:=/*.cc) -f- 2> /dev/null | grep -v Cint | grep -v "/usr/" > Makefile.depend && \
+	makedepend -- $(INCLUDES) -- $(PROGRAMS:=.cc) $(SRCS) $(SUBDIRS:=/*.cc) -w1024 -f- 2> /dev/null | grep -v Cint | grep -v "/usr/" > Makefile.depend && \
 	echo " ") || find -maxdepth 0 -true > /dev/null
 
-Makefile.depend: depend
+depend:	Makefile.depend	
 
 # @endcode
Index: trunk/MagicSoft/Mars/Makefile.conf.darwin
===================================================================
--- trunk/MagicSoft/Mars/Makefile.conf.darwin	(revision 2490)
+++ trunk/MagicSoft/Mars/Makefile.conf.darwin	(revision 2491)
@@ -29,5 +29,6 @@
 # For producing gmon.out use    '-pg'
 
-MARS_LIB = -Llib $(SUBDIRS:%=-l%) $(MARSLIBS)
+#MARS_LIB = -Llib $(SUBDIRS:%=-l%) $(MARSLIBS)
+MARS_LIB = -Llib $(MARSLIBS)
 INCLUDES = -I. $(SUBDIRS:%=-I%)
 
Index: trunk/MagicSoft/Mars/Makefile.conf.linux
===================================================================
--- trunk/MagicSoft/Mars/Makefile.conf.linux	(revision 2490)
+++ trunk/MagicSoft/Mars/Makefile.conf.linux	(revision 2491)
@@ -27,7 +27,8 @@
 
 # For debugging information use '-g'
-# For producing gmon.out use    '-pg'
+# For producing gmon.out use    '-pg' (needs static linking)
 
-MARS_LIB = -Llib $(SUBDIRS:%=-l%) $(MARSLIBS)
+#MARS_LIB = -Llib $(SUBDIRS:%=-l%) $(MARSLIBS)
+MARS_LIB = -Llib $(MARSLIBS)
 INCLUDES = -I. $(SUBDIRS:%=-I%)
 
Index: trunk/MagicSoft/Mars/Makefile.conf.linux-gnu
===================================================================
--- trunk/MagicSoft/Mars/Makefile.conf.linux-gnu	(revision 2490)
+++ trunk/MagicSoft/Mars/Makefile.conf.linux-gnu	(revision 2491)
@@ -21,5 +21,5 @@
 
 OPTIM    = -O5 -Wall -fno-rtti -fnonnull-objects -fno-exceptions -fPIC -Wtraditional -Wpointer-arith -Wcast-align -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Woverloaded-virtual
-DEBUG    =
+DEBUG    = 
 ARCHDEF  = -D__LINUX__
 DYNLIB   = -shared
@@ -32,5 +32,6 @@
 # For producing gmon.out use    '-pg'
 
-MARS_LIB = -Llib $(SUBDIRS:%=-l%)  $(MARSLIBS)
+#MARS_LIB = -Llib $(SUBDIRS:%=-l%)  $(MARSLIBS)
+MARS_LIB = -Llib  $(MARSLIBS)
 INCLUDES = -I. $(SUBDIRS:%=-I%)
 
Index: trunk/MagicSoft/Mars/Makefile.conf.osf1
===================================================================
--- trunk/MagicSoft/Mars/Makefile.conf.osf1	(revision 2490)
+++ trunk/MagicSoft/Mars/Makefile.conf.osf1	(revision 2491)
@@ -28,5 +28,6 @@
 DYNLIB   = -shared
 
-MARS_LIB = -Llib $(SUBDIRS/*/-l&)  $(MARSLIBS)
+#MARS_LIB = -Llib $(SUBDIRS/*/-l&)  $(MARSLIBS)
+MARS_LIB = -Llib $(MARSLIBS)
 INCLUDES = -I. $(SUBDIRS/*/-I&)
 
Index: trunk/MagicSoft/Mars/Makefile.conf.osf5.1
===================================================================
--- trunk/MagicSoft/Mars/Makefile.conf.osf5.1	(revision 2490)
+++ trunk/MagicSoft/Mars/Makefile.conf.osf5.1	(revision 2491)
@@ -28,5 +28,6 @@
 DYNLIB   = -shared
 
-MARS_LIB = -Llib $(SUBDIRS/*/-l&)  $(MARSLIBS)
+#MARS_LIB = -Llib $(SUBDIRS/*/-l&)  $(MARSLIBS)
+MARS_LIB = -Llib $(MARSLIBS)
 INCLUDES = -I. $(SUBDIRS/*/-I&)
 
Index: trunk/MagicSoft/Mars/macros/rootlogon.C
===================================================================
--- trunk/MagicSoft/Mars/macros/rootlogon.C	(revision 2490)
+++ trunk/MagicSoft/Mars/macros/rootlogon.C	(revision 2491)
@@ -25,5 +25,5 @@
 Bool_t isloaded()
 {
-    TString str = gSystem->GetLibraries("*/mars.so");
+    TString str = gSystem->GetLibraries("libmars.so");
 
     return !str.IsNull();
@@ -35,6 +35,6 @@
         return;
 
-    cout << "Unloading 'mars.so'... " << flush;
-    if (gSystem->Unload("mars.so"))
+    cout << "Unloading 'libmars.so'... " << flush;
+    if (gSystem->Unload("libmars.so"))
         cout << "error." << endl;
     else
@@ -47,7 +47,7 @@
         return;
 
-    cout << "Loading 'mars.so'... " << flush;
+    cout << "Loading 'libmars.so'... " << flush;
 
-    if (gSystem->Load(dir.IsNull() ? "mars.so" : dir+"lib/mars.so")!=0)
+    if (gSystem->Load(dir.IsNull() ? "libmars.so" : dir+"libmars.so")!=0)
         cout << "error." << endl;
     else
@@ -106,4 +106,5 @@
     gInterpreter->AddIncludePath(dir+"mranforest");
     gInterpreter->AddIncludePath(dir+"mraw");
+    gInterpreter->AddIncludePath(dir+"mreflector");
     gInterpreter->AddIncludePath(dir+"mtools");
 
Index: trunk/MagicSoft/Mars/mars.cc
===================================================================
--- trunk/MagicSoft/Mars/mars.cc	(revision 2490)
+++ trunk/MagicSoft/Mars/mars.cc	(revision 2491)
@@ -76,9 +76,4 @@
 int main(int argc, char **argv)
 {
-#ifdef HAVE_XPM
-    MLogo logo;
-    logo.Popup();
-#endif
-
     StartUpMessage();
 
@@ -121,4 +116,9 @@
     else
         gLog.SetDebugLevel(2);
+
+#ifdef HAVE_XPM
+    MLogo logo;
+    logo.Popup();
+#endif
 
     //
Index: trunk/MagicSoft/Mars/mbase/MLog.cc
===================================================================
--- trunk/MagicSoft/Mars/mbase/MLog.cc	(revision 2490)
+++ trunk/MagicSoft/Mars/mbase/MLog.cc	(revision 2491)
@@ -101,4 +101,5 @@
 
 #ifdef _REENTRANT
+// FIXME: Replace Mutex by TMutex
 #include <pthread.h>
 #endif
Index: trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mmain/MStatusDisplay.cc	(revision 2490)
+++ 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 2490)
+++ 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);
