OCC22403 Avoid long recursion in the method Transfer_Binder::CutResult
authorMSV <>
Thu, 28 Apr 2011 15:37:01 +0000 (15:37 +0000)
committerbugmaster <bugmaster@opencascade.com>
Mon, 5 Mar 2012 15:28:06 +0000 (19:28 +0400)
src/Transfer/Transfer_Binder.cxx

index 6a911f2..c37f9aa 100755 (executable)
@@ -61,7 +61,7 @@ void  Transfer_Binder::AddResult (const Handle(Transfer_Binder)& next)
   if (thenextr.IsNull()) 
     thenextr = next;
   else {
-    //Modification of requrcive to cycle
+    //Modification of recursive to cycle
     Handle(Transfer_Binder) theBinder = thenextr;
     while( theBinder != next ) { 
       if( theBinder->NextResult().IsNull() ) {
@@ -72,7 +72,7 @@ void  Transfer_Binder::AddResult (const Handle(Transfer_Binder)& next)
         theBinder = theBinder->NextResult();
     }
   }
-  //former requrcive
+  //former recursive
   // if (thenextr.IsNull()) thenextr = next;
   // else if (thenextr == next) return;
   // else thenextr->AddResult (next);
@@ -87,7 +87,16 @@ void  Transfer_Binder::CutResult (const Handle(Transfer_Binder)& next)
 {
   if (thenextr.IsNull()) return;
   if (thenextr == next) thenextr.Nullify();
-  else thenextr->CutResult (next);
+  //else thenextr->CutResult (next);
+  else {
+    Handle(Transfer_Binder) currBinder = thenextr, currNext;
+    while( !( (currNext = currBinder->NextResult()) == next ) ) {
+      if( currNext.IsNull() )
+        return;
+      currBinder = currNext;
+    }
+    currBinder->CutResult(next);
+  }
 }
 
 //=======================================================================