]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Fixed double delete of fESDObjects
authorkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 16 Jul 2007 11:56:09 +0000 (11:56 +0000)
committerkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 16 Jul 2007 11:56:09 +0000 (11:56 +0000)
STEER/AliESDEvent.cxx
STEER/AliESDEvent.h

index 669d27e44f6a2d9dddd67d467c49a651053cffc2..a7e82636400095ef0eb239db900d4573d2fc52d9 100644 (file)
@@ -177,7 +177,6 @@ AliESDEvent & AliESDEvent::operator=(const AliESDEvent& source) {
   AddObject(fCaloClusters);
   AddObject(fErrorLogs);
 
-
   fEMCALClusters = source.fEMCALClusters;
   fFirstEMCALCluster = source.fFirstEMCALCluster;
   fPHOSClusters = source.fPHOSClusters;
@@ -198,8 +197,11 @@ AliESDEvent::~AliESDEvent()
   //
 
   // everthing on the list gets deleted automatically
-  delete fESDObjects;
+
+  
+  if(fESDObjects)delete fESDObjects;
   fESDObjects = 0;
+
 }
 
 //______________________________________________________________________________
@@ -500,16 +502,19 @@ void AliESDEvent::ReadFromTree(TTree *tree){
 
   if(esdEvent){   
       // Check if already connected to tree
-//      TList* connectedList = (TList*) (tree->GetTree()->GetUserInfo()->FindObject("ESDObjectsConnectedToTree"));
-      TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree"));
-      if (connectedList) {
-         // If connected use the connected list if objects
-         fESDObjects->Delete();
-         fESDObjects = connectedList;
-         GetStdContent();
-         return;
+    TList* connectedList = (TList*) (tree->GetUserInfo()->FindObject("ESDObjectsConnectedToTree"));
+    if (connectedList) {
+      // If connected use the connected list if objects
+      fESDObjects->Delete();
+      //         fESDObjects = connectedList; 
+      fESDObjects = new TList();
+      // place the pointers in the list...
+      for(int i = 0;i < connectedList->GetEntries();i++){
+       fESDObjects->Add(connectedList->At(i));
       }
-      // Connect to tree
+      return;
+    }
+    // Connect to tree
     if(fESDObjects->GetEntries()!=0){
       // this should not happen here put a warning?
     }
@@ -519,6 +524,7 @@ void AliESDEvent::ReadFromTree(TTree *tree){
     // create a new TList from the UserInfo TList... 
     // copy constructor does not work...
     fESDObjects = (TList*)(esdEvent->GetList()->Clone());
+    fESDObjects->SetOwner(kFALSE);
     if(fESDObjects->GetEntries()<kESDListN){
       printf("%s %d AliESDEvent::ReadFromTree() TList contains less than the standard contents %d < %d \n",
             (char*)__FILE__,__LINE__,fESDObjects->GetEntries(),kESDListN);
@@ -542,9 +548,20 @@ void AliESDEvent::ReadFromTree(TTree *tree){
     // when reading back we are not owner of the list 
     // must not delete it
     fESDObjects->SetOwner(kFALSE);
+
+    // will be deleted when closing the file
+    TList *conList = new TList();
+
+    // place the pointers in the list...
+    for(int i = 0;i < fESDObjects->GetEntries();i++){
+      conList->Add(fESDObjects->At(i));
+    }    
     // Add list to user info
-    fESDObjects->SetName("ESDObjectsConnectedToTree");
-    tree->GetUserInfo()->Add(fESDObjects);
+    conList->SetName("ESDObjectsConnectedToTree");
+    // we are not owner of the list objects 
+    // must not delete it
+    conList->SetOwner(kFALSE);
+    tree->GetUserInfo()->Add(conList);
   }// no esdEvent
   else {
     // we can't get the list from the user data, create standard content
index e7e38f2b19f924c52dd25886ecbd91c64d580152..35c39f06332a1f78bc316ce2a3cfa37a299e5a2c 100644 (file)
@@ -351,7 +351,6 @@ protected:
 
   AliESD    *fESDOld;              //! Old esd Structure
 
-
   // Remove this stuff CKB
   Int_t        fEMCALClusters;   // Number of EMCAL clusters (subset of caloclusters)
   Int_t        fFirstEMCALCluster; // First EMCAL cluster in the fCaloClusters list