From: eap Date: Fri, 4 Oct 2013 14:25:30 +0000 (+0000) Subject: Some protection from usage of removed objects whose data label X-Git-Tag: BR_hydro_v_0_3_1~108 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4e2d22a173a4649ae7828a70ecd9c1dbc7d46e82;p=modules%2Fgeom.git Some protection from usage of removed objects whose data label is reused by a new object --- diff --git a/src/GEOM/GEOM_Engine.cxx b/src/GEOM/GEOM_Engine.cxx index 711ef4595..f486e24c0 100644 --- a/src/GEOM/GEOM_Engine.cxx +++ b/src/GEOM/GEOM_Engine.cxx @@ -462,7 +462,12 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_BaseObject)& theObject) //Remove an object from the map of available objects TCollection_AsciiString anID = BuildIDFromObject(theObject); - if (_objects.IsBound(anID)) _objects.UnBind(anID); + if (_objects.IsBound(anID)) { + Handle(GEOM_BaseObject) anObject = Handle(GEOM_BaseObject)::DownCast(_objects(anID)); + if ( anObject != theObject ) + anObject->_label = anObject->_label.Root(); + _objects.UnBind(anID); + } // If sub-shape, remove it from the list of sub-shapes of its main shape Handle(GEOM_Object) aGO = Handle(GEOM_Object)::DownCast( theObject ); @@ -491,6 +496,13 @@ bool GEOM_Engine::RemoveObject(Handle(GEOM_BaseObject)& theObject) if ( aFreeLabels.empty() || aFreeLabels.back() != aLabel ) aFreeLabels.push_back(aLabel); + // we can't explicitely delete theObject. At least prevent its functioning + // as an alive object when aLabel is reused for a new object + theObject->_label = aLabel.Root(); + theObject->_ior.Clear(); + theObject->_parameters.Clear(); + theObject->_docID = -1; + theObject.Nullify(); return true;