From: mpv Date: Fri, 26 Oct 2018 14:19:39 +0000 (+0300) Subject: Make TestIntersection work: no crash on remove of PaveFiller before all algorithm... X-Git-Tag: End2018~259 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2f1373605447e46fccf4081701e21de153eecf11;p=modules%2Fshaper.git Make TestIntersection work: no crash on remove of PaveFiller before all algorithm is destroyed. --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.cpp index 5793dbf0b..49b7fe423 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.cpp @@ -27,10 +27,15 @@ //================================================================================================== GeomAlgoAPI_Intersection::GeomAlgoAPI_Intersection(const ListOfShape& theObjects) + : myFiller(0) { build(theObjects); } +GeomAlgoAPI_Intersection::~GeomAlgoAPI_Intersection() { + if (myFiller) + delete (BOPAlgo_PaveFiller*)myFiller; +} //================================================================================================== void GeomAlgoAPI_Intersection::build(const ListOfShape& theObjects) { @@ -53,21 +58,22 @@ void GeomAlgoAPI_Intersection::build(const ListOfShape& theObjects) } } - BOPAlgo_PaveFiller aDSFiller; - aDSFiller.SetArguments(anObjects); + BOPAlgo_PaveFiller* aDSFiller = new BOPAlgo_PaveFiller; + myFiller = aDSFiller; + aDSFiller->SetArguments(anObjects); - aDSFiller.SetRunParallel(false); - aDSFiller.SetNonDestructive(false); - aDSFiller.SetGlue(BOPAlgo_GlueOff); + aDSFiller->SetRunParallel(false); + aDSFiller->SetNonDestructive(false); + aDSFiller->SetGlue(BOPAlgo_GlueOff); // optimization for the issue #2399 BOPAlgo_SectionAttribute theSecAttr(Standard_True, Standard_True, Standard_True); - aDSFiller.SetSectionAttribute(theSecAttr); + aDSFiller->SetSectionAttribute(theSecAttr); - aDSFiller.Perform(); - if (aDSFiller.HasErrors()) { + aDSFiller->Perform(); + if (aDSFiller->HasErrors()) { return; } @@ -75,7 +81,7 @@ void GeomAlgoAPI_Intersection::build(const ListOfShape& theObjects) anOperation->SetRunParallel(false); anOperation->SetCheckInverted(true); - anOperation->PerformWithFiller(aDSFiller); + anOperation->PerformWithFiller(*aDSFiller); // it references a filler fields, so keep the filler if(anOperation->HasErrors()) { return; } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.h b/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.h index 2ea3e0c14..bd0511769 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Intersection.h @@ -31,15 +31,20 @@ /// \brief Performs the intersection operations. class GeomAlgoAPI_Intersection : public GeomAlgoAPI_MakeShape { + void* myFiller; ///< store filler to avoid memory leaks public: /// \brief Constructor. /// \param[in] theObjects list of objects. /// \param[in] theTools list of tools. GEOMALGOAPI_EXPORT GeomAlgoAPI_Intersection(const ListOfShape& theObjects); + /// Destructor to erase the filler + GEOMALGOAPI_EXPORT virtual ~GeomAlgoAPI_Intersection(); + private: /// Builds resulting shape. void build(const ListOfShape& theObjects); + }; #endif