diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index 09355aa4a0..033ab1ef40 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -14694,6 +14694,26 @@ static int VSelBvhBuild (Draw_Interpretor& /*theDI*/, Standard_Integer theNbArgs return 0; } +//======================================================================= +//function : ViewerTest_ExitProc +//purpose : +//======================================================================= +static void ViewerTest_ExitProc (ClientData ) +{ + NCollection_List aViewList; + for (NCollection_DoubleMap::Iterator anIter (ViewerTest_myViews); + anIter.More(); anIter.Next()) + { + aViewList.Append (anIter.Key1()); + } + + for (NCollection_List::Iterator anIter (aViewList); + anIter.More(); anIter.Next()) + { + ViewerTest::RemoveView (anIter.Value(), true); + } +} + //======================================================================= //function : ViewerCommands //purpose : @@ -14701,6 +14721,15 @@ static int VSelBvhBuild (Draw_Interpretor& /*theDI*/, Standard_Integer theNbArgs void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands) { + static bool TheIsInitialized = false; + if (TheIsInitialized) + { + return; + } + + TheIsInitialized = true; + // define destruction callback to destroy views in a well-defined order + Tcl_CreateExitHandler (ViewerTest_ExitProc, 0); const char *group = "ZeViewer"; theCommands.Add("vinit",