瀏覽代碼

memory leak

Ken Martin 24 年之前
父節點
當前提交
b502515ad1
共有 1 個文件被更改,包括 9 次插入1 次删除
  1. 9 1
      Source/cmVTKWrapTclCommand.cxx

+ 9 - 1
Source/cmVTKWrapTclCommand.cxx

@@ -269,6 +269,14 @@ bool cmVTKWrapTclCommand::WriteInit(const char *kitName,
   /* create an extern ref to the generic delete function */
   fprintf(fout,"\nextern void vtkTclGenericDeleteObject(ClientData cd);\n");
 
+  if (!strcmp(kitName,"Vtkcommontcl"))
+    {
+    fprintf(fout,"void vtkCommonDeleteAssocData(ClientData cd, Tcl_Interp *)\n");
+    fprintf(fout,"  {\n");
+    fprintf(fout,"  vtkTclInterpStruct *tis = static_cast<vtkTclInterpStruct*>(cd);\n");
+    fprintf(fout,"  delete tis;\n  }\n");
+    }
+    
   /* the main declaration */
   fprintf(fout,"\n\nint VTK_EXPORT %s_SafeInit(Tcl_Interp *interp)\n{\n",kitName);
   fprintf(fout,"  return %s_Init(interp);\n}\n",kitName);
@@ -290,7 +298,7 @@ bool cmVTKWrapTclCommand::WriteInit(const char *kitName,
     fprintf(fout,
 	    "  Tcl_InitHashTable(&info->CommandLookup, TCL_STRING_KEYS);\n");
     fprintf(fout,
-            "  Tcl_SetAssocData(interp,(char *) \"vtk\",NULL,(ClientData *)info);\n");
+            "  Tcl_SetAssocData(interp,(char *) \"vtk\",vtkCommonDeleteAssocData,(ClientData *)info);\n");
 
     /* create special vtkCommand command */
     fprintf(fout,"  Tcl_CreateCommand(interp,(char *) \"vtkCommand\",vtkCommand,\n		    (ClientData *)NULL, NULL);\n\n");