From 2e1a3c2b141bd982d298838d5d05e565edaf542b Mon Sep 17 00:00:00 2001 From: guigues Date: Thu, 13 Nov 2008 10:37:27 +0000 Subject: [PATCH] Fixed another ugly bug with bbmgGlobalProcessExecutionList (unhandled rentrance / list insertion while iterating which invalidated iterators !) --- kernel/src/bbtkBlackBox.cxx | 60 ++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/kernel/src/bbtkBlackBox.cxx b/kernel/src/bbtkBlackBox.cxx index 859430f..6d134c9 100644 --- a/kernel/src/bbtkBlackBox.cxx +++ b/kernel/src/bbtkBlackBox.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkBlackBox.cxx,v $ Language: C++ - Date: $Date: 2008/11/12 15:42:52 $ - Version: $Revision: 1.26 $ + Date: $Date: 2008/11/13 10:37:27 $ + Version: $Revision: 1.27 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -1127,32 +1127,38 @@ namespace bbtk } //========================================================================= + static bool bbmgGlobalProcessingExecutionList = false; //========================================================================= void BlackBox::bbGlobalProcessExecutionList() { bbtkDebugMessageInc("process",3, "=> BlackBox::bbGlobalProcessExecutionList()" - <::iterator i; - for (i=bbmgExecutionList.begin(); - i!=bbmgExecutionList.end(); - ++i) + < Executing "<< - (*i).lock()->bbGetFullName()<bbExecute(true); - } - else - { - bbtkGlobalError("Strange error in BlackBox::bbGlobalProcessExecutionList() : Weak bb pointer in bbmgExecutionList is no more valid..."); - } - } + bbtkDebugMessage("process",3,"BlackBox::bbGlobalProcessExecutionList() reentered !"); + return; + } + bbmgGlobalProcessingExecutionList = true; + + std::set::iterator i; + while (bbmgExecutionList.size()>0) + { + i = bbmgExecutionList.begin(); + BlackBox::WeakPointer p = *i; + bbmgExecutionList.erase(i); + if (p.lock()) + { + bbtkDebugMessage("process",4, + " -> Executing "<< + p.lock()->bbGetFullName()<bbExecute(true); + } + else + { + bbtkGlobalError("Strange error in BlackBox::bbGlobalProcessExecutionList() : Weak bb pointer in bbmgExecutionList is no more valid..."); + } } bbmgExecutionList.clear(); @@ -1160,6 +1166,7 @@ namespace bbtk "<= BlackBox::bbGlobalProcessExecutionList()" <bbGetFullName()<<")"<