From 16a855524cdb854cd3770d116ba2ace0a9e160bd Mon Sep 17 00:00:00 2001
From: Gerardo Ganis <Gerardo.Ganis@cern.ch>
Date: Wed, 9 Apr 2008 07:17:22 +0000
Subject: [PATCH] Ask for next packet on TFile::Open failures (instead of
 exiting the loop)

git-svn-id: http://root.cern.ch/svn/root/trunk@23070 27541ba8-7e3a-0410-8455-c3a389f83636
---
 proof/proofplayer/src/TEventIter.cxx | 47 +++++++++++++++-------------
 1 file changed, 26 insertions(+), 21 deletions(-)

diff --git a/proof/proofplayer/src/TEventIter.cxx b/proof/proofplayer/src/TEventIter.cxx
index a46821796f5..52d444e6ecf 100644
--- a/proof/proofplayer/src/TEventIter.cxx
+++ b/proof/proofplayer/src/TEventIter.cxx
@@ -349,7 +349,7 @@ Long64_t TEventIterObj::GetNextEvent()
 
       // Position within this element. TODO: more efficient?
       fNextKey->Reset();
-      for(fElemCur = -1; fElemCur < fElemFirst-1 ; fElemCur++, fNextKey->Next()) { }
+      for(fElemCur = -1; fElemCur < fElemFirst-1 ; fElemCur++, fNextKey->Next());
    }
 
    --fElemNum;
@@ -622,28 +622,33 @@ Long64_t TEventIterTree::GetNextEvent()
       }
 
       SafeDelete(fElem);
-      if (fTree) {
-         fElem = fDSet->Next(fTree->GetEntries());
-      } else {
-         fElem = fDSet->Next();
-      }
+      while (!fElem) {
+         if (fTree) {
+            fElem = fDSet->Next(fTree->GetEntries());
+         } else {
+            fElem = fDSet->Next();
+         }
 
-      if ( fElem == 0 ) {
-         fNum = 0;
-         return -1;
-      }
+         if (!fElem) {
+            // End of processing
+            fNum = 0;
+            return -1;
+         }
 
-      TTree *newTree = GetTrees(fElem);
-      if (!newTree) {
-         // Error has been reported
-         fNum = 0;
-         return -1;
-      }
-      if (newTree != fTree) {
-         // The old tree is wonwd by TFileTree and will be deleted there
-         fTree = newTree;
-         attach = kTRUE;
-         fOldBytesRead = fTree->GetCurrentFile()->GetBytesRead();
+         TTree *newTree = GetTrees(fElem);
+         if (newTree) {
+            if (newTree != fTree) {
+               // The old tree is wonwd by TFileTree and will be deleted there
+               fTree = newTree;
+               attach = kTRUE;
+               fOldBytesRead = fTree->GetCurrentFile()->GetBytesRead();
+            }
+         } else {
+            // Could not open this element: ask for another one
+            SafeDelete(fElem);
+            // The current tree, if any, is not valid anymore
+            fTree = 0;
+         }
       }
 
       // Validate values for this element
-- 
GitLab