]> Creatis software - bbtk.git/commitdiff
Fixed another ugly bug with bbmgGlobalProcessExecutionList (unhandled rentrance ...
authorguigues <guigues>
Thu, 13 Nov 2008 10:37:27 +0000 (10:37 +0000)
committerguigues <guigues>
Thu, 13 Nov 2008 10:37:27 +0000 (10:37 +0000)
kernel/src/bbtkBlackBox.cxx

index 859430f349098c23951b9cd75b3d9e4c245ad42f..6d134c9ce3faae64d0c348add99e51c91ab78f3e 100644 (file)
@@ -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()"
-                        <<std::endl);     
-     
-     std::set<BlackBox::WeakPointer>::iterator i;
-     for (i=bbmgExecutionList.begin();
-         i!=bbmgExecutionList.end();
-         ++i)
+                        <<std::endl);    
+     if (bbmgGlobalProcessingExecutionList) 
        {
-        {
-          if ((*i).lock())
-            {
-              bbtkDebugMessage("process",4,
-                               " -> Executing "<<
-                               (*i).lock()->bbGetFullName()<<std::endl);
-              (*i).lock()->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<BlackBox::WeakPointer>::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()<<std::endl);
+            p.lock()->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()"
                         <<std::endl);     
      
+     bbmgGlobalProcessingExecutionList = false;
      
    }
   //=========================================================================
@@ -1185,9 +1192,14 @@ namespace bbtk
        }
 
   void BlackBox::bbGlobalAddToExecutionList( BlackBox::Pointer b )
-       {  
-               bbmgExecutionList.insert(b); 
-       } 
+  {  
+    bbtkDebugMessage("process",3,"* bbGlobalAddToExecutionList("<<b->bbGetFullName()<<")"<<std::endl);
+    if (bbmgGlobalProcessingExecutionList) 
+      {
+       bbtkDebugMessage("process",3,"bbGlobalAddToExecutionList called inside bbGlobalProcessExecutionList !");
+      }
+    bbmgExecutionList.insert(b); 
+  } 
 
 
    //=========================================================================