Commit 8ae60a79 authored by Brad King's avatar Brad King
Browse files

ENH: TclCommand now creates its own copy of the command string when SetStringCommand is called.

parent d36303ec
......@@ -583,7 +583,14 @@ vtkTclCommand::vtkTclCommand()
vtkTclCommand::~vtkTclCommand()
{
delete [] this->StringCommand;
if(this->StringCommand) { delete [] this->StringCommand; }
}
void vtkTclCommand::SetStringCommand(const char *arg)
{
if(this->StringCommand) { delete [] this->StringCommand; }
this->StringCommand = new char[strlen(arg)+1];
strcpy(this->StringCommand, arg);
}
void vtkTclCommand::Execute(vtkObject *, unsigned long, void *)
......
......@@ -91,7 +91,7 @@ public:
~vtkTclCommand();
static vtkTclCommand *New() { return new vtkTclCommand; };
void SetStringCommand(char *arg) { this->StringCommand = arg; };
void SetStringCommand(const char *arg);
void SetInterp(Tcl_Interp *interp) { this->Interp = interp; };
void Execute(vtkObject *, unsigned long, void *);
......
......@@ -691,7 +691,7 @@ void vtkParseOutput(FILE *fp, FileInfo *data)
fprintf(fp," if ((!strcmp(\"AddObserver\",argv[1]))&&(argc == 4))\n {\n");
fprintf(fp," vtkTclCommand *cbc = new vtkTclCommand;\n");
fprintf(fp," cbc->SetInterp(interp);\n");
fprintf(fp," cbc->SetStringCommand(strcpy(new char [strlen(argv[3])+1],argv[3]));\n");
fprintf(fp," cbc->SetStringCommand(argv[3]);\n");
fprintf(fp," unsigned long temp20;\n");
fprintf(fp," temp20 = op->AddObserver(argv[2],cbc);\n");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment