0026324: Visualization - fix iteration through corrupted memory in AIS_LocalContext...
authorvpa <vpa@opencascade.com>
Mon, 8 Jun 2015 14:52:17 +0000 (17:52 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 10 Jun 2015 08:03:00 +0000 (11:03 +0300)
The signature of SelectMgr_ViewerSelector::ActiveOwners is changed to return output parameter to avoid crash

src/AIS/AIS_LocalContext_1.cxx
src/SelectMgr/SelectMgr_ViewerSelector.cxx
src/SelectMgr/SelectMgr_ViewerSelector.hxx

index 7a405b6..5b5cb97 100644 (file)
@@ -1454,8 +1454,10 @@ Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromShape(const
   Standard_Boolean found(Standard_False);
 
   if (!found) {
-    NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (myMainVS->ActiveOwners());
-    for (; anOwnersIt.More(); anOwnersIt.Next()) {
+    NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
+    myMainVS->ActiveOwners (anActiveOwners);
+    for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (anActiveOwners); anOwnersIt.More(); anOwnersIt.Next())
+    {
       EO = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value());
       Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(EO);
       if (!BROwnr.IsNull() && BROwnr->HasShape() && BROwnr->Shape() == sh) {
index 28a1200..8a5190f 100644 (file)
@@ -839,9 +839,8 @@ const Handle(SelectBasics_SensitiveEntity)& SelectMgr_ViewerSelector::DetectedEn
 // function : ActiveOwners
 // purpose  : Returns the list of active entity owners
 //=======================================================================
-NCollection_List<Handle(SelectBasics_EntityOwner)> SelectMgr_ViewerSelector::ActiveOwners() const
+void SelectMgr_ViewerSelector::ActiveOwners (NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners) const
 {
-  NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
   for (SelectMgr_MapOfObjectSensitivesIterator anIter (myMapOfObjectSensitives); anIter.More(); anIter.Next())
   {
     const NCollection_Handle<SelectMgr_SensitiveEntitySet>& anEntitySet = anIter.Value();
@@ -850,10 +849,8 @@ NCollection_List<Handle(SelectBasics_EntityOwner)> SelectMgr_ViewerSelector::Act
     {
       if (anEntitySet->GetSensitiveById (anIdx)->IsActiveForSelection())
       {
-        anActiveOwners.Append (anEntitySet->GetSensitiveById (anIdx)->BaseSensitive()->OwnerId());
+        theOwners.Append (anEntitySet->GetSensitiveById (anIdx)->BaseSensitive()->OwnerId());
       }
     }
   }
-
-  return anActiveOwners;
 }
index 3f9def3..0d95e77 100644 (file)
@@ -203,7 +203,7 @@ public:
   Standard_EXPORT TCollection_AsciiString Status (const Handle(SelectMgr_SelectableObject)& theSelectableObject) const;
 
   //! Returns the list of active entity owners
-  Standard_EXPORT NCollection_List<Handle(SelectBasics_EntityOwner)> ActiveOwners() const;
+  Standard_EXPORT void ActiveOwners (NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners) const;
 
   //! Adds new object to the map of selectable objects
   Standard_EXPORT void AddSelectableObject (const Handle(SelectMgr_SelectableObject)& theObject);