mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0023005: Unjustified memory grow during undo/redo operation
This commit is contained in:
parent
b67106756f
commit
0f524ba023
@ -281,6 +281,8 @@ void NIS_Drawer::removeObject (const NIS_InteractiveObject * theObj,
|
|||||||
SetDynamicHilighted (Standard_False, theObj);
|
SetDynamicHilighted (Standard_False, theObj);
|
||||||
if (myMapID.IsEmpty()) {
|
if (myMapID.IsEmpty()) {
|
||||||
UpdateExListId(NULL);
|
UpdateExListId(NULL);
|
||||||
|
// Remove the drawer from context.
|
||||||
|
myCtx->myDrawers.Remove(this);
|
||||||
}
|
}
|
||||||
// Set Updated for the draw type.
|
// Set Updated for the draw type.
|
||||||
else if (theObj->IsHidden() == Standard_False && isUpdateViews)
|
else if (theObj->IsHidden() == Standard_False && isUpdateViews)
|
||||||
|
@ -22,12 +22,14 @@ static void markAllDrawersUpdated (const NCollection_Map<Handle_NIS_Drawer>&);
|
|||||||
|
|
||||||
NIS_InteractiveContext::NIS_InteractiveContext ()
|
NIS_InteractiveContext::NIS_InteractiveContext ()
|
||||||
: myAllocator (new NIS_Allocator(1024*100)),
|
: myAllocator (new NIS_Allocator(1024*100)),
|
||||||
|
myLastObjectId (0),
|
||||||
|
myObjects (1000),
|
||||||
// myDrawers (101, myAllocator),
|
// myDrawers (101, myAllocator),
|
||||||
mySelectionMode (Mode_NoSelection),
|
mySelectionMode (Mode_NoSelection),
|
||||||
myIsShareDrawList (Standard_True)
|
myIsShareDrawList (Standard_True)
|
||||||
{
|
{
|
||||||
// ID == 0 is invalid so we reserve this item from subsequent allocation.
|
// ID == 0 is invalid so we reserve this item from subsequent allocation.
|
||||||
myObjects.Append (NULL);
|
myObjects.SetValue(myLastObjectId, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -107,6 +109,22 @@ void NIS_InteractiveContext::DetachView (const Handle_NIS_View& theView)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : GetObject
|
||||||
|
//purpose :
|
||||||
|
//=======================================================================
|
||||||
|
|
||||||
|
const Handle_NIS_InteractiveObject& NIS_InteractiveContext::GetObject
|
||||||
|
(const Standard_Integer theID) const
|
||||||
|
{
|
||||||
|
if (!myObjects.IsBound(theID))
|
||||||
|
{
|
||||||
|
static Handle_NIS_InteractiveObject aNull;
|
||||||
|
return aNull;
|
||||||
|
}
|
||||||
|
return myObjects(theID);
|
||||||
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : redraw
|
//function : redraw
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -236,7 +254,8 @@ void NIS_InteractiveContext::Remove (const Handle_NIS_InteractiveObject& theObj,
|
|||||||
aDrawer->removeObject(theObj.operator->(), isUpdateViews);
|
aDrawer->removeObject(theObj.operator->(), isUpdateViews);
|
||||||
theObj->myID = 0;
|
theObj->myID = 0;
|
||||||
theObj->myDrawer.Nullify();
|
theObj->myDrawer.Nullify();
|
||||||
myObjects(anID).Nullify();
|
myObjects.UnsetValue(anID);
|
||||||
|
myMapNonSelectableObjects.Remove(anID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,7 +268,8 @@ void NIS_InteractiveContext::Remove (const Handle_NIS_InteractiveObject& theObj,
|
|||||||
void NIS_InteractiveContext::DisplayAll ()
|
void NIS_InteractiveContext::DisplayAll ()
|
||||||
{
|
{
|
||||||
// UnHide all objects in the Context
|
// UnHide all objects in the Context
|
||||||
NCollection_Vector <Handle_NIS_InteractiveObject>::Iterator anIter(myObjects);
|
NCollection_SparseArray <Handle_NIS_InteractiveObject>::ConstIterator
|
||||||
|
anIter(myObjects);
|
||||||
for (; anIter.More(); anIter.Next()) {
|
for (; anIter.More(); anIter.Next()) {
|
||||||
const Handle(NIS_InteractiveObject)& anObj = anIter.Value();
|
const Handle(NIS_InteractiveObject)& anObj = anIter.Value();
|
||||||
if (anObj.IsNull() == Standard_False)
|
if (anObj.IsNull() == Standard_False)
|
||||||
@ -278,7 +298,8 @@ void NIS_InteractiveContext::DisplayAll ()
|
|||||||
void NIS_InteractiveContext::EraseAll ()
|
void NIS_InteractiveContext::EraseAll ()
|
||||||
{
|
{
|
||||||
// Hide all objects in the Context
|
// Hide all objects in the Context
|
||||||
NCollection_Vector <Handle_NIS_InteractiveObject>::Iterator anIter(myObjects);
|
NCollection_SparseArray <Handle_NIS_InteractiveObject>::ConstIterator
|
||||||
|
anIter(myObjects);
|
||||||
for (; anIter.More(); anIter.Next()) {
|
for (; anIter.More(); anIter.Next()) {
|
||||||
const Handle(NIS_InteractiveObject)& anObj = anIter.Value();
|
const Handle(NIS_InteractiveObject)& anObj = anIter.Value();
|
||||||
if (anObj.IsNull() == Standard_False) {
|
if (anObj.IsNull() == Standard_False) {
|
||||||
@ -319,7 +340,8 @@ void NIS_InteractiveContext::EraseAll ()
|
|||||||
void NIS_InteractiveContext::RemoveAll ()
|
void NIS_InteractiveContext::RemoveAll ()
|
||||||
{
|
{
|
||||||
// Remove objects from the Context
|
// Remove objects from the Context
|
||||||
NCollection_Vector <Handle_NIS_InteractiveObject>::Iterator anIter(myObjects);
|
NCollection_SparseArray <Handle_NIS_InteractiveObject>::Iterator
|
||||||
|
anIter(myObjects);
|
||||||
for (; anIter.More(); anIter.Next()) {
|
for (; anIter.More(); anIter.Next()) {
|
||||||
Handle(NIS_InteractiveObject)& anObj = anIter.ChangeValue();
|
Handle(NIS_InteractiveObject)& anObj = anIter.ChangeValue();
|
||||||
if (anObj.IsNull() == Standard_False) {
|
if (anObj.IsNull() == Standard_False) {
|
||||||
@ -352,14 +374,13 @@ void NIS_InteractiveContext::RemoveAll ()
|
|||||||
myAllocator->Reset();
|
myAllocator->Reset();
|
||||||
myAllocator->ResetCounters();
|
myAllocator->ResetCounters();
|
||||||
|
|
||||||
myDrawers.Clear();
|
|
||||||
|
|
||||||
// Remove objects from maps
|
// Remove objects from maps
|
||||||
myMapObjects[0].Clear();
|
myMapObjects[0].Clear();
|
||||||
myMapObjects[1].Clear();
|
myMapObjects[1].Clear();
|
||||||
myMapObjects[2].Clear();
|
myMapObjects[2].Clear();
|
||||||
myMapObjects[3].Clear();
|
myMapObjects[3].Clear();
|
||||||
myMapNonSelectableObjects.Clear();
|
myMapNonSelectableObjects.Clear();
|
||||||
|
myObjects.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -634,7 +655,7 @@ Standard_Real NIS_InteractiveContext::selectObject
|
|||||||
if (mySelectionMode != Mode_NoSelection || isOnlySel == Standard_False)
|
if (mySelectionMode != Mode_NoSelection || isOnlySel == Standard_False)
|
||||||
{
|
{
|
||||||
DetectedEnt anEnt;
|
DetectedEnt anEnt;
|
||||||
NCollection_Vector <Handle_NIS_InteractiveObject>::Iterator
|
NCollection_SparseArray <Handle_NIS_InteractiveObject>::ConstIterator
|
||||||
anIter(myObjects);
|
anIter(myObjects);
|
||||||
for (; anIter.More(); anIter.Next()) {
|
for (; anIter.More(); anIter.Next()) {
|
||||||
const Handle(NIS_InteractiveObject)& anObj = anIter.Value();
|
const Handle(NIS_InteractiveObject)& anObj = anIter.Value();
|
||||||
@ -716,7 +737,7 @@ Standard_Boolean NIS_InteractiveContext::selectObjects
|
|||||||
{
|
{
|
||||||
Standard_Boolean aResult (Standard_False);
|
Standard_Boolean aResult (Standard_False);
|
||||||
if (mySelectionMode != Mode_NoSelection) {
|
if (mySelectionMode != Mode_NoSelection) {
|
||||||
NCollection_Vector <Handle_NIS_InteractiveObject>::Iterator
|
NCollection_SparseArray <Handle_NIS_InteractiveObject>::ConstIterator
|
||||||
anIter(myObjects);
|
anIter(myObjects);
|
||||||
for (; anIter.More(); anIter.Next()) {
|
for (; anIter.More(); anIter.Next()) {
|
||||||
const Handle(NIS_InteractiveObject)& anObj = anIter.Value();
|
const Handle(NIS_InteractiveObject)& anObj = anIter.Value();
|
||||||
@ -758,7 +779,7 @@ Standard_Boolean NIS_InteractiveContext::selectObjects
|
|||||||
Standard_Boolean aResult (Standard_False);
|
Standard_Boolean aResult (Standard_False);
|
||||||
|
|
||||||
if (mySelectionMode != Mode_NoSelection) {
|
if (mySelectionMode != Mode_NoSelection) {
|
||||||
NCollection_Vector <Handle_NIS_InteractiveObject>::Iterator
|
NCollection_SparseArray <Handle_NIS_InteractiveObject>::ConstIterator
|
||||||
anIter(myObjects);
|
anIter(myObjects);
|
||||||
|
|
||||||
for (; anIter.More(); anIter.Next()) {
|
for (; anIter.More(); anIter.Next()) {
|
||||||
@ -894,8 +915,8 @@ void NIS_InteractiveContext::objectForDisplay
|
|||||||
Handle(NIS_InteractiveObject) anObj;
|
Handle(NIS_InteractiveObject) anObj;
|
||||||
theObj->Clone(myAllocator, anObj);
|
theObj->Clone(myAllocator, anObj);
|
||||||
theObj = anObj;
|
theObj = anObj;
|
||||||
anObj->myID = myObjects.Length();
|
anObj->myID = ++myLastObjectId;
|
||||||
myObjects.Append (anObj);
|
myObjects.SetValue (myLastObjectId, anObj);
|
||||||
myMapObjects[theDrawType].Add(anObj->myID);
|
myMapObjects[theDrawType].Add(anObj->myID);
|
||||||
anObj->myDrawType = theDrawType;
|
anObj->myDrawType = theDrawType;
|
||||||
}
|
}
|
||||||
@ -928,7 +949,7 @@ Handle_NIS_Allocator NIS_InteractiveContext::compactObjects()
|
|||||||
// Compact the memory: clone all objects to a new allocator, release
|
// Compact the memory: clone all objects to a new allocator, release
|
||||||
// the old allocator instance.
|
// the old allocator instance.
|
||||||
aNewAlloc = new NIS_Allocator;
|
aNewAlloc = new NIS_Allocator;
|
||||||
NCollection_Vector<Handle_NIS_InteractiveObject>::Iterator
|
NCollection_SparseArray<Handle_NIS_InteractiveObject>::Iterator
|
||||||
anIter(myObjects);
|
anIter(myObjects);
|
||||||
for (; anIter.More(); anIter.Next()) {
|
for (; anIter.More(); anIter.Next()) {
|
||||||
if (anIter.Value().IsNull() == Standard_False) {
|
if (anIter.Value().IsNull() == Standard_False) {
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <Handle_NIS_InteractiveObject.hxx>
|
#include <Handle_NIS_InteractiveObject.hxx>
|
||||||
#include <Handle_NIS_View.hxx>
|
#include <Handle_NIS_View.hxx>
|
||||||
#include <NCollection_Map.hxx>
|
#include <NCollection_Map.hxx>
|
||||||
#include <NCollection_Vector.hxx>
|
#include <NCollection_SparseArray.hxx>
|
||||||
#include <NIS_Allocator.hxx>
|
#include <NIS_Allocator.hxx>
|
||||||
#include <NIS_Drawer.hxx>
|
#include <NIS_Drawer.hxx>
|
||||||
#include <NIS_SelectFilter.hxx>
|
#include <NIS_SelectFilter.hxx>
|
||||||
@ -155,9 +155,8 @@ class NIS_InteractiveContext : public Standard_Transient
|
|||||||
/**
|
/**
|
||||||
* Query the InteractiveObject instance by its ID.
|
* Query the InteractiveObject instance by its ID.
|
||||||
*/
|
*/
|
||||||
inline const Handle_NIS_InteractiveObject&
|
Standard_EXPORT const Handle_NIS_InteractiveObject&
|
||||||
GetObject (const Standard_Integer theID) const
|
GetObject (const Standard_Integer theID) const;
|
||||||
{ return myObjects(theID); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query the total number of InteractiveObject instances. This number can be
|
* Query the total number of InteractiveObject instances. This number can be
|
||||||
@ -572,10 +571,15 @@ private:
|
|||||||
*/
|
*/
|
||||||
Handle_NIS_Allocator myAllocator;
|
Handle_NIS_Allocator myAllocator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The last added object ID.
|
||||||
|
*/
|
||||||
|
Standard_Integer myLastObjectId;
|
||||||
/**
|
/**
|
||||||
* Container of InteractiveObject instances.
|
* Container of InteractiveObject instances.
|
||||||
*/
|
*/
|
||||||
NCollection_Vector <Handle_NIS_InteractiveObject> myObjects;
|
NCollection_SparseArray <Handle_NIS_InteractiveObject>
|
||||||
|
myObjects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of Views.
|
* List of Views.
|
||||||
|
@ -16,7 +16,7 @@ void NIS_ObjectsIterator::Initialize
|
|||||||
(const Handle(NIS_InteractiveContext)& theCtx)
|
(const Handle(NIS_InteractiveContext)& theCtx)
|
||||||
{
|
{
|
||||||
if (theCtx.IsNull())
|
if (theCtx.IsNull())
|
||||||
myIter = NCollection_Vector <Handle_NIS_InteractiveObject>::Iterator();
|
myIter = NCollection_SparseArray <Handle_NIS_InteractiveObject>::Iterator();
|
||||||
else
|
else
|
||||||
for (myIter.Init (theCtx->myObjects); myIter.More(); myIter.Next())
|
for (myIter.Init (theCtx->myObjects); myIter.More(); myIter.Next())
|
||||||
if (myIter.Value().IsNull() == Standard_False)
|
if (myIter.Value().IsNull() == Standard_False)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#ifndef NIS_ObjectsIterator_HeaderFile
|
#ifndef NIS_ObjectsIterator_HeaderFile
|
||||||
#define NIS_ObjectsIterator_HeaderFile
|
#define NIS_ObjectsIterator_HeaderFile
|
||||||
|
|
||||||
#include <NCollection_Vector.hxx>
|
#include <NCollection_SparseArray.hxx>
|
||||||
#include <Handle_NIS_InteractiveObject.hxx>
|
#include <Handle_NIS_InteractiveObject.hxx>
|
||||||
|
|
||||||
class Handle_NIS_InteractiveContext;
|
class Handle_NIS_InteractiveContext;
|
||||||
@ -80,7 +80,7 @@ class NIS_ObjectsIterator
|
|||||||
protected:
|
protected:
|
||||||
// ---------- PROTECTED FIELDS ----------
|
// ---------- PROTECTED FIELDS ----------
|
||||||
|
|
||||||
NCollection_Vector <Handle_NIS_InteractiveObject>::Iterator myIter;
|
NCollection_SparseArray <Handle_NIS_InteractiveObject>::ConstIterator myIter;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user