[vtkusers] Bugs in vtkSource

Carsten Kübler kuebler at ira.uka.de
Thu Jan 30 03:13:20 EST 2003


Hello,

yesterday I found one bug and maybe a second in vtkSource.
One question: Which is the right email adress to send a bug report?

Carsten





This is maybe a bug.

	void vtkSource::SetNumberOfOutputs(int num)
	{
	...

	  // Allocate new arrays.
	  outputs = new vtkDataObject *[num];

	...
	}

After removing the output of a vtkSource object the method
SetNumberOfOutputs creates an array with zero size. It would be better to
create no array and set the pointer to NULL.

	void vtkSource::SetNumberOfOutputs(int num)
	{
	...

	  // Allocate new arrays.
	  outputs = NULL;
	  if (num > 0)
	  {
	    outputs = new vtkDataObject *[num];
	  }

	...
	}


Second: This is a bug.

void vtkSource::RemoveOutput(vtkDataObject *output)
{
...

  this->Outputs[loc]->SetSource(NULL);
  this->Outputs[loc]->UnRegister(this);
  this->Outputs[loc] = NULL;

  // if that was the last output, then shrink the list
  if (loc == this->NumberOfOutputs - 1)
    {
    this->SetNumberOfOutputs(this->NumberOfOutputs - 1);
    }

...
}


this->Outputs[loc]->SetSource(NULL):
  If you remove an output, the output's source is set to NULL.
  If you set the output's source to NULL, the output unregisters itself from
the source.
  The source shrinkt resp. change its Outputs array.

this->Outputs[loc]->UnRegister(this):
  This can't be called, because the Outputs array has been changed!!!
...

void vtkSource::RemoveOutput(vtkDataObject *output)
{
...

  this->Outputs[loc] = NULL;

  // if that was the last output, then shrink the list
  if (loc == this->NumberOfOutputs - 1)
  {
    this->SetNumberOfOutputs(this->NumberOfOutputs - 1);
  }

  output->SetSource(NULL);
  output->UnRegister(this);

...
}



And here is an example. (It is really not nice but I think it is correct)
p2->SetOutput(pd); crashes!!!


	vtkPlaneSource *p1;
		p1 = vtkPlaneSource::New();

	vtkPolyData *pd;
		pd = p1->GetOutput();
		pd->Register(NULL);
		p1->Delete();

	vtkPlaneSource *p2;
		p2 = vtkPlaneSource::New();

		p2->SetOutput(pd);

		p2->Delete();
		pd->Update();
		pd->UnRegister();





More information about the vtkusers mailing list