]> OCCT Git - occt-copy.git/commitdiff
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)
committerdbv <dbv@opencascade.com>
Wed, 17 Jun 2015 07:33:40 +0000 (10:33 +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 04c094d8962d4955f6d6d420591f882694ef4a94..21e44575e82addb5df0e5b54d41c3ce9262521c5 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 28a12000fc9f8cd85156681f2736b305ed4f7d96..8a5190f7f73e756044dcddb64c292396729210bb 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 3f9def378b2b06ec744761db74273f2e8e639b3e..0d95e77fd319ff03eb2f5c9f877ef556bc194b52 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);