From: vsv Date: Tue, 31 Mar 2015 14:43:47 +0000 (+0300) Subject: Free memory on deletion of handle object X-Git-Tag: V_1.1.0~71 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=028f504e56e0cd3b5f7cc8921327515887504c7b;p=modules%2Fshaper.git Free memory on deletion of handle object --- diff --git a/src/GeomAPI/GeomAPI_AISObject.cpp b/src/GeomAPI/GeomAPI_AISObject.cpp index 8f053f7cf..57d192bba 100644 --- a/src/GeomAPI/GeomAPI_AISObject.cpp +++ b/src/GeomAPI/GeomAPI_AISObject.cpp @@ -41,6 +41,17 @@ GeomAPI_AISObject::GeomAPI_AISObject() { } +GeomAPI_AISObject::~GeomAPI_AISObject() +{ + if (myImpl) { + // This is necessary for correct deletion of Handle entity. + // Without this Handle does not decremented counter to 0 + Handle(AIS_InteractiveObject) *anAIS = (Handle(AIS_InteractiveObject)*)myImpl; + anAIS->Nullify(); + } +} + + void GeomAPI_AISObject::createShape(std::shared_ptr theShape) { const TopoDS_Shape& aTDS = diff --git a/src/GeomAPI/GeomAPI_AISObject.h b/src/GeomAPI/GeomAPI_AISObject.h index ad879d1db..06bc2e905 100644 --- a/src/GeomAPI/GeomAPI_AISObject.h +++ b/src/GeomAPI/GeomAPI_AISObject.h @@ -28,6 +28,8 @@ class GEOMAPI_EXPORT GeomAPI_AISObject : public GeomAPI_Interface /// \brief Creation of empty AIS object GeomAPI_AISObject(); + ~GeomAPI_AISObject(); + /// \brief Creates AIS_Shape object using specified shape void createShape(std::shared_ptr theShape); diff --git a/src/GeomAPI/GeomAPI_Interface.cpp b/src/GeomAPI/GeomAPI_Interface.cpp index 1ee1a6213..4db15c996 100644 --- a/src/GeomAPI/GeomAPI_Interface.cpp +++ b/src/GeomAPI/GeomAPI_Interface.cpp @@ -18,8 +18,10 @@ GeomAPI_Interface::GeomAPI_Interface(void* theImpl) GeomAPI_Interface::~GeomAPI_Interface() { - if (myImpl) + if (myImpl) { delete myImpl; + myImpl = 0; + } } void GeomAPI_Interface::setImpl(void* theImpl)