mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-04 18:06:22 +03:00
0027318: Memory is not released in Select3D_SensitiveSet when destroying AIS_InteractiveContext without removing objects
- destructor was added to SelectMgr_SelectableObject to clean up selections; - test case for issue #27318 Warnings elimination
This commit is contained in:
parent
16b40363d3
commit
4c0d97ac42
@ -5140,6 +5140,26 @@ static Standard_Integer OCC27065(Draw_Interpretor& di,
|
||||
return 0;
|
||||
}
|
||||
|
||||
//========================================================================
|
||||
//function : OCC27318
|
||||
//purpose : Creates a box that is not listed in map of AIS objects of ViewerTest
|
||||
//========================================================================
|
||||
static Standard_Integer OCC27318 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
|
||||
{
|
||||
const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
|
||||
if (aCtx.IsNull())
|
||||
{
|
||||
std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TopoDS_Shape aBox = BRepPrimAPI_MakeBox (20, 20, 20).Shape();
|
||||
Handle(AIS_Shape) aBoxObj = new AIS_Shape (aBox);
|
||||
aCtx->Display (aBoxObj, Standard_True);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QABugs::Commands_19(Draw_Interpretor& theCommands) {
|
||||
const char *group = "QABugs";
|
||||
|
||||
@ -5253,6 +5273,10 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
|
||||
theCommands.Add ("OCC27065",
|
||||
"OCC27065 spine profile",
|
||||
__FILE__, OCC27065, group);
|
||||
|
||||
|
||||
theCommands.Add ("OCC27318",
|
||||
"OCC27318: Creates a box that is not listed in map of AIS objects of ViewerTest",
|
||||
__FILE__, OCC27318, group);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -69,6 +69,17 @@ SelectMgr_SelectableObject::SelectMgr_SelectableObject (const PrsMgr_TypeOfPrese
|
||||
myHilightDrawer->Link (myDrawer);
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: Destructor
|
||||
// Purpose : Clears all selections of the object
|
||||
//==================================================
|
||||
SelectMgr_SelectableObject::~SelectMgr_SelectableObject()
|
||||
{
|
||||
for (Standard_Integer aSelIdx = 1; aSelIdx <= myselections.Length(); ++aSelIdx)
|
||||
{
|
||||
myselections.Value (aSelIdx)->Clear();
|
||||
}
|
||||
}
|
||||
|
||||
//==================================================
|
||||
// Function: HasSelection
|
||||
|
@ -56,6 +56,8 @@ class SelectMgr_SelectableObject : public PrsMgr_PresentableObject
|
||||
|
||||
public:
|
||||
|
||||
//! Clears all selections of the object
|
||||
Standard_EXPORT virtual ~SelectMgr_SelectableObject();
|
||||
|
||||
//! Recovers and calculates any sensitive primitive,
|
||||
//! aSelection, available in Shape mode, specified by
|
||||
|
35
tests/bugs/vis/bug27318
Normal file
35
tests/bugs/vis/bug27318
Normal file
@ -0,0 +1,35 @@
|
||||
puts "========"
|
||||
puts "OCC27318"
|
||||
puts "========"
|
||||
puts ""
|
||||
##################################################################
|
||||
puts "Memory is not released in Select3D_SensitiveSet when destroying AIS_InteractiveContext without removing objects"
|
||||
##################################################################
|
||||
|
||||
pload VISUALIZATION QAcommands
|
||||
|
||||
# to measure initial memory correctly, open and close interactive context
|
||||
# to load FreeImage
|
||||
vinit
|
||||
vclose
|
||||
set aMemInit [meminfo h]
|
||||
puts "Initial mem: [expr $aMemInit / (1024 * 1024)] MiB ([expr $aMemInit])"
|
||||
|
||||
# create a box and display it in each interactive context. The context is
|
||||
# the only instance that references to the box. Therefore, the box must be
|
||||
# removed completely after each context's closing
|
||||
for {set anIter 0} {$anIter < 300} {incr anIter} {
|
||||
vinit
|
||||
OCC27318
|
||||
vclose
|
||||
}
|
||||
|
||||
set aMemAfter [meminfo h]
|
||||
puts "Memory after closing interactive context several times: [expr $aMemAfter / (1024 * 1024)] MiB ([expr $aMemAfter])"
|
||||
|
||||
set aRatio [expr $aMemAfter / double($aMemInit)]
|
||||
|
||||
# check if the memory difference is greater than 5%
|
||||
if [expr $aRatio > 1.05] {
|
||||
puts "Error : TEST FAILED"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user