From 3fa24667b1090f714aad1dbe3ab05ad8d66f1f81 Mon Sep 17 00:00:00 2001
From: Gerardo Ganis <Gerardo.Ganis@cern.ch>
Date: Wed, 31 Aug 2011 12:46:32 +0000
Subject: [PATCH] Make sure that iterators are always correctly defined

git-svn-id: http://root.cern.ch/svn/root/trunk@40776 27541ba8-7e3a-0410-8455-c3a389f83636
---
 proof/proofbench/src/TProofNodes.cxx | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/proof/proofbench/src/TProofNodes.cxx b/proof/proofbench/src/TProofNodes.cxx
index f7ca277ecc9..41739c537ee 100644
--- a/proof/proofbench/src/TProofNodes.cxx
+++ b/proof/proofbench/src/TProofNodes.cxx
@@ -188,11 +188,10 @@ Int_t TProofNodes::ActivateWorkers(const char *workers)
    Int_t nworkersnode = sworkers.Atoi();
    Int_t ret = nworkersnode;
    TSlaveInfo *si = 0;
-   TIter nxtnode(fNodes);
    TList *node = 0;
-   TIter nxk(fNodes);
    TObject *key = 0;
 
+   TIter nxk(fNodes);
    while ((key = nxk()) != 0) {
       if ((node = dynamic_cast<TList *>(fNodes->GetValue(key)))) {
          TIter nxtworker(node);
@@ -239,8 +238,9 @@ Int_t TProofNodes::ActivateWorkers(const char *workers)
    // Rebuild
    Build();
 
-   nxk.Reset();
-   while ((key = nxk()) != 0) {
+   // Build() destroyes fNodes so we need to re-create the iterator, resetting is not enough ...
+   TIter nxkn(fNodes);
+   while ((key = nxkn()) != 0) {
       if ((node = dynamic_cast<TList *>(fNodes->GetValue(key)))) {
          TIter nxtworker(node);
          Int_t nactiveworkers = 0;
-- 
GitLab