]> OCCT Git - occt.git/commitdiff
0032207: Draw Harness, ViewerTest - explicitly close 3D Viewer windows at Tcl interpr...
authorkgv <kgv@opencascade.com>
Wed, 10 Mar 2021 11:17:41 +0000 (14:17 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 17 Mar 2021 16:52:22 +0000 (19:52 +0300)
src/ViewerTest/ViewerTest_ViewerCommands.cxx

index 09355aa4a0a386e3397af82cf3b3d536a3076ec1..033ab1ef40fa7fd9cf15dd138c4a8b9767c4f149 100644 (file)
@@ -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<TCollection_AsciiString> aViewList;
+  for (NCollection_DoubleMap<TCollection_AsciiString, Handle(V3d_View)>::Iterator anIter (ViewerTest_myViews);
+       anIter.More(); anIter.Next())
+  {
+    aViewList.Append (anIter.Key1());
+  }
+
+  for (NCollection_List<TCollection_AsciiString>::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",