1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0031075: Application Framework - reading STEP file into TDocStd_Document leads to memory leaks

In the TDocStd_Owner keep simple pointer to TDocStd_Document instead of Handle. This causes automatic destruction of the document without explicit call of Close.
In Standard_Type added a static variable theType that initializes theRegistry map earlier. Otherwise exit from Draw interpreter crashes in many test-cases because not-closed transactions are aborted on document handle release from Draw theVariables map.

Corrected method for test OCC159bug due to the fact that Owner does not add a ref count now
Close the document in the end of bugs xde bug22776 otherwise double remove of visualization objects (on library exit and on visualization attributes remove from the document) causes crash on exit from draw
Added a new test bugs caf bug31075
This commit is contained in:
mpv
2020-06-18 10:24:07 +03:00
committed by bugmaster
parent 003c363cf4
commit ef779ae0da
10 changed files with 89 additions and 16 deletions

View File

@@ -110,6 +110,14 @@ myAllowModification (Standard_True)
void TDF_Data::Destroy()
{
AbortUntilTransaction(1);
// Forget the Owner attribute from the root label to avoid referencing document before
// desctuction of the framework (on custom attributes forget). Don't call ForgetAll because
// it may call backup.
while(!myRoot->FirstAttribute().IsNull()) {
static Handle(TDF_Attribute) anEmpty;
Handle(TDF_Attribute) aFirst = myRoot->FirstAttribute();
myRoot->RemoveAttribute(anEmpty, aFirst);
}
myRoot->Destroy (myLabelNodeAllocator);
myRoot = NULL;
}