I'm having a problem removing objects from my AIS_InteractiveContext. Within my application I load a BRep file and create an AIS_Shape object like this:
Handle(AIS_Shape) myShapeHandle = new AIS_Shape(myTopoDS_Shape);
Reference Counter is now 1;
Afterwards I display the AIS_Shape using AIS_InteractiveContext::Display(myShapeHandle);
Reference Counter is now 3;
The handle is stored in a class. When I want to change the BRep file I have to remove the AIS_Shape first from the viewer. I'm doing this using AIS_InteractiveContext::Remove(myShapeHandle);
Reference Counter decreases to 2 ==> Should decrease to 1, but doesn't!!! Why???
Afterwards I Nullify the handle to release the memory of the AIS_Shape object.
Nullify decreases the Reference Counter first by one and then checks whether the counter is 0. If so the delete operator of AIS_Shape is called, to release its memory.
As the Remove() function does (That's my problem!!!) decrease the Reference Counter only by 1 and not by 2. The memory is not released and I get a memory leak if I read a new BRep file and assign the new AIS_Shape object to the same handle.
Another OCC user already has reported to me that when he uses the Remove() function the corresponding reference counter is decreased correctly by 2 from 3 to 1. So I wonder why within my application I am having this problem.
Does anyone have a clue what could be wrong?
Thanks in advance and best regards.