From 4e2d22a173a4649ae7828a70ecd9c1dbc7d46e82 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 4 Oct 2013 14:25:30 +0000 Subject: [PATCH] Some protection from usage of removed objects whose data label is reused by a new object --- src/GEOM/GEOM_Engine.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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; -- 2.39.2