0029973: Modeling Algorithms - access violation within BRepAlgoAPI_Cut on empty input...
[occt.git] / src / BOPAlgo / BOPAlgo_BuilderShape.hxx
index ffdf8b1..15e469b 100644 (file)
@@ -99,9 +99,23 @@ public: //! @name History methods
   }
 
   //! History Tool
-  Handle(BRepTools_History) History() const
+  Handle(BRepTools_History) History()
   {
-    return myFillHistory ? myHistory : NULL;
+    if (myFillHistory)
+    {
+      if (myHistory.IsNull())
+       // It seems the algorithm has exited with error before filling
+       // the history. Initialize the History tool to return the empty
+       // History instead of NULL.
+       myHistory = new BRepTools_History();
+
+      return myHistory;
+    }
+
+    // If the History has not been requested to be filled, return the NULL
+    // explicitly as the History may be partially filled for the algorithm's
+    // internal needs.
+    return NULL;
   }
 
 public: //! @name Enabling/Disabling the history collection.