[vtk-developers] Re: [vtkusers] Unconnected filter(s) causing seg faults

Berk Geveci berk.geveci at kitware.com
Thu Oct 16 16:45:15 EDT 2003


> Well, I had another look, and it seems SetNumberOfInputs() also 
> allocates the input array, so it can be construed as correct for a 
> filter to call SetNumberOfInputs(1) in its constructor.  See 
> vtkProcessObject::SetNumberOfInputs().

SetNthInput (therefore SetInput) also allocates the input array.
Therefore, calling  SetNumberOfInputs() prematurely is not necessary. 
If you create a filter and call GetNumberOfInputs(), would you expect 
it to return 0 or 1? I would expect it to return 0 since I have not
assigned an input yet. However, I agree that it is not that
straightforward since after
filter SetInput foo
filter SetInput ""

filter GetNumberOfOutputs returns 1.


> To reiterate: I think your plan of actually checking the number of 
> non-null inputs against the NumberOfRequiredInputs in vtkSource.cxx is 
> good.  I grepped through all the C++ source, and NumberOfRequiredInputs 
> isn't being checked anywhere else than in vtkSource.cxx.

I will commit this fix tomorrow. It is still useful to write a test
to check for filters that crash when executed without inputs. In
case some of them overwrite UpdateData() or do not set
NumberOfRequiredInputs. Any volunteers? :-)

-Berk





More information about the vtk-developers mailing list