Index: trunk/MagicSoft/Mars/mgui/MCamDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 1276)
+++ trunk/MagicSoft/Mars/mgui/MCamDisplay.cc	(revision 1325)
@@ -27,7 +27,7 @@
 //
 MCamDisplay::MCamDisplay(MGeomCam *geom)
-    : fAutoScale(kTRUE), fMinPhe(-2), fMaxPhe(50), fW(0), fH(0), fDrawingPad(NULL)
-{
-    fGeomCam = geom; // FIXME: Clone doesn't work! (MGeomCam*)geom->Clone();
+    : fAutoScale(kTRUE), fMinPhe(-2), fMaxPhe(50), fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)
+{
+    fGeomCam = (MGeomCam*)geom; // FIXME: Clone doesn't work! (MGeomCam*)geom->Clone();
 
     //
@@ -53,5 +53,9 @@
     // set the color palette for the TBox elements
     //
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)
     gStyle->SetPalette(1, 0);
+#else
+    gStyle->SetPalette(51, 0);
+#endif
 
     //
@@ -81,9 +85,16 @@
 MCamDisplay::~MCamDisplay()
 {
+    fPixels->Delete();
+    fLegend->Delete();
+    fLegText->Delete();
+
     delete fPixels;
     delete fLegend;
     delete fLegText;
 
-    delete fGeomCam;
+    // delete fGeomCam;
+
+    if (fIsAllocated)
+        delete fDrawingPad;
 }
 
@@ -157,11 +168,20 @@
     // gPad->SetFixedAspectRatio()
 
+    if (fDrawingPad)
+        return;
+
     //
     // if no canvas is yet existing to draw into, create a new one
     //
     if (!gPad)
+    {
         fDrawingPad = new TCanvas("CamDisplay", "Magic Camera Display", 0, 0, 750, 600);
+        fIsAllocated = kTRUE;
+    }
     else
+    {
         fDrawingPad = gPad;
+        fIsAllocated = kFALSE;
+    }
 
     fDrawingPad->SetBorderMode(0);
@@ -176,5 +196,9 @@
     // Setup the correct environment
     //
+#if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06)
     gStyle->SetPalette(1, 0);
+#else
+    gStyle->SetPalette(51, 0);
+#endif
 
     gPad->SetFillColor(22);
@@ -220,4 +244,7 @@
 void MCamDisplay::DrawPhotNum(const MCerPhotEvt *event)
 {
+    if (!event)
+        return;
+
     if (!fDrawingPad)
         Draw();
Index: trunk/MagicSoft/Mars/mgui/MCamDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 1276)
+++ trunk/MagicSoft/Mars/mgui/MCamDisplay.h	(revision 1325)
@@ -38,4 +38,5 @@
     UInt_t         fH;           // Height of canvas
     TVirtualPad   *fDrawingPad;  // pad in which we are drawing
+    Bool_t         fIsAllocated;
 
     TBox  *GetBox(Int_t i)  { return (TBox*) fLegend->At(i); }
