Salome HOME
Free memory on deletion of handle object
[modules/shaper.git] / src / GeomAPI / GeomAPI_AISObject.cpp
index f4ae420490bada6d8d4b177459ba93c67198fb94..57d192bbac49556cfb921e703022e28009797cfe 100644 (file)
@@ -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<GeomAPI_Shape> theShape)
 {
   const TopoDS_Shape& aTDS =
@@ -311,9 +322,9 @@ void GeomAPI_AISObject::getColor(int& theR, int& theG, int& theB)
     return;
 
   Quantity_Color aColor = anAIS->Color();
-  theR = aColor.Red()*255.;
-  theG = aColor.Green()*255.;
-  theB = aColor.Blue()*255.;
+  theR = (int)(aColor.Red()*255.);
+  theG = (int)(aColor.Green()*255.);
+  theB = (int)(aColor.Blue()*255.);
 }
 
 bool GeomAPI_AISObject::empty() const